cozy-client 51.6.1 → 52.0.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 +70 -47
- package/dist/CozyClient.spec.js +15 -15
- package/dist/CozyLink.js +9 -8
- package/dist/CozyLink.spec.js +12 -12
- package/dist/StackLink.js +19 -12
- package/dist/WebFlagshipLink.js +4 -4
- package/dist/associations.spec.js +2 -1
- package/dist/index.js +20 -2
- package/dist/index.node.js +20 -2
- package/dist/performances/defaultPerformanceApi.js +15 -0
- package/dist/performances/types.js +26 -0
- package/dist/performances/webPerformanceApi.js +60 -0
- package/dist/store/index.js +49 -24
- package/dist/store/queries.js +34 -11
- package/dist/store/queries.spec.js +2 -1
- package/dist/store.spec.js +4 -1
- package/dist/types.js +1 -0
- package/package.json +3 -3
- package/types/CozyClient.d.ts +8 -1
- package/types/CozyLink.d.ts +2 -1
- package/types/StackLink.d.ts +9 -2
- package/types/index.d.ts +2 -0
- package/types/index.node.d.ts +2 -0
- package/types/performances/defaultPerformanceApi.d.ts +2 -0
- package/types/performances/types.d.ts +25 -0
- package/types/performances/webPerformanceApi.d.ts +2 -0
- package/types/store/index.d.ts +3 -3
- package/types/store/queries.d.ts +2 -1
- package/types/types.d.ts +4 -0
package/dist/WebFlagshipLink.js
CHANGED
|
@@ -76,12 +76,12 @@ var WebFlagshipLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
76
76
|
}, {
|
|
77
77
|
key: "request",
|
|
78
78
|
value: function () {
|
|
79
|
-
var _request = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(operation, result, forward) {
|
|
79
|
+
var _request = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(operation, options, result, forward) {
|
|
80
80
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
81
81
|
while (1) {
|
|
82
82
|
switch (_context2.prev = _context2.next) {
|
|
83
83
|
case 0:
|
|
84
|
-
return _context2.abrupt("return", this.webviewIntent.call('flagshipLinkRequest', operation));
|
|
84
|
+
return _context2.abrupt("return", this.webviewIntent.call('flagshipLinkRequest', operation, options));
|
|
85
85
|
|
|
86
86
|
case 1:
|
|
87
87
|
case "end":
|
|
@@ -91,7 +91,7 @@ var WebFlagshipLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
91
91
|
}, _callee2, this);
|
|
92
92
|
}));
|
|
93
93
|
|
|
94
|
-
function request(_x, _x2, _x3) {
|
|
94
|
+
function request(_x, _x2, _x3, _x4) {
|
|
95
95
|
return _request.apply(this, arguments);
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -115,7 +115,7 @@ var WebFlagshipLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
115
115
|
}, _callee3);
|
|
116
116
|
}));
|
|
117
117
|
|
|
118
|
-
function persistCozyData(
|
|
118
|
+
function persistCozyData(_x5, _x6) {
|
|
119
119
|
return _persistCozyData.apply(this, arguments);
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import CozyClient from './CozyClient'
|
|
2
2
|
import CozyLink from './CozyLink'
|
|
3
|
+
import { defaultPerformanceApi } from './performances/defaultPerformanceApi'
|
|
3
4
|
import { createStore, getQueryFromStore } from './store'
|
|
4
5
|
import { receiveQueryResult, initQuery } from './store/queries'
|
|
5
6
|
|
|
@@ -21,7 +22,7 @@ describe('Associations', () => {
|
|
|
21
22
|
.shift()
|
|
22
23
|
|
|
23
24
|
beforeEach(async () => {
|
|
24
|
-
const store = createStore()
|
|
25
|
+
const store = createStore(defaultPerformanceApi)
|
|
25
26
|
client.setStore(store, { force: true })
|
|
26
27
|
await store.dispatch(initQuery('allTodos', { doctype: 'io.cozy.todos' }))
|
|
27
28
|
await store.dispatch(
|
package/dist/index.js
CHANGED
|
@@ -58,7 +58,9 @@ var _exportNames = {
|
|
|
58
58
|
withClient: true,
|
|
59
59
|
models: true,
|
|
60
60
|
fetchPolicies: true,
|
|
61
|
-
BulkEditError: true
|
|
61
|
+
BulkEditError: true,
|
|
62
|
+
webPerformanceApi: true,
|
|
63
|
+
defaultPerformanceApi: true
|
|
62
64
|
};
|
|
63
65
|
Object.defineProperty(exports, "default", {
|
|
64
66
|
enumerable: true,
|
|
@@ -360,6 +362,18 @@ Object.defineProperty(exports, "BulkEditError", {
|
|
|
360
362
|
return _errors.BulkEditError;
|
|
361
363
|
}
|
|
362
364
|
});
|
|
365
|
+
Object.defineProperty(exports, "webPerformanceApi", {
|
|
366
|
+
enumerable: true,
|
|
367
|
+
get: function get() {
|
|
368
|
+
return _webPerformanceApi.webPerformanceApi;
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
Object.defineProperty(exports, "defaultPerformanceApi", {
|
|
372
|
+
enumerable: true,
|
|
373
|
+
get: function get() {
|
|
374
|
+
return _defaultPerformanceApi.defaultPerformanceApi;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
363
377
|
exports.models = exports.manifest = void 0;
|
|
364
378
|
|
|
365
379
|
var _CozyClient = _interopRequireDefault(require("./CozyClient"));
|
|
@@ -436,4 +450,8 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
436
450
|
});
|
|
437
451
|
});
|
|
438
452
|
|
|
439
|
-
var _errors = require("./errors");
|
|
453
|
+
var _errors = require("./errors");
|
|
454
|
+
|
|
455
|
+
var _webPerformanceApi = require("./performances/webPerformanceApi");
|
|
456
|
+
|
|
457
|
+
var _defaultPerformanceApi = require("./performances/defaultPerformanceApi");
|
package/dist/index.node.js
CHANGED
|
@@ -38,7 +38,9 @@ var _exportNames = {
|
|
|
38
38
|
manifest: true,
|
|
39
39
|
BulkEditError: true,
|
|
40
40
|
models: true,
|
|
41
|
-
fetchPolicies: true
|
|
41
|
+
fetchPolicies: true,
|
|
42
|
+
webPerformanceApi: true,
|
|
43
|
+
defaultPerformanceApi: true
|
|
42
44
|
};
|
|
43
45
|
Object.defineProperty(exports, "default", {
|
|
44
46
|
enumerable: true,
|
|
@@ -220,6 +222,18 @@ Object.defineProperty(exports, "fetchPolicies", {
|
|
|
220
222
|
return _policies.default;
|
|
221
223
|
}
|
|
222
224
|
});
|
|
225
|
+
Object.defineProperty(exports, "webPerformanceApi", {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: function get() {
|
|
228
|
+
return _webPerformanceApi.webPerformanceApi;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
Object.defineProperty(exports, "defaultPerformanceApi", {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
get: function get() {
|
|
234
|
+
return _defaultPerformanceApi.defaultPerformanceApi;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
223
237
|
exports.models = exports.manifest = void 0;
|
|
224
238
|
|
|
225
239
|
var _CozyClient = _interopRequireDefault(require("./CozyClient"));
|
|
@@ -282,4 +296,8 @@ var models = _interopRequireWildcard(require("./models"));
|
|
|
282
296
|
|
|
283
297
|
exports.models = models;
|
|
284
298
|
|
|
285
|
-
var _policies = _interopRequireDefault(require("./policies"));
|
|
299
|
+
var _policies = _interopRequireDefault(require("./policies"));
|
|
300
|
+
|
|
301
|
+
var _webPerformanceApi = require("./performances/webPerformanceApi");
|
|
302
|
+
|
|
303
|
+
var _defaultPerformanceApi = require("./performances/defaultPerformanceApi");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultPerformanceApi = void 0;
|
|
7
|
+
|
|
8
|
+
/** @type {import('./types').PerformanceAPI} */
|
|
9
|
+
var defaultPerformanceApi = {
|
|
10
|
+
measure: function measure(options) {},
|
|
11
|
+
mark: function mark(markName) {
|
|
12
|
+
return markName;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.defaultPerformanceApi = defaultPerformanceApi;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {'primary' | 'primary-light' | 'primary-dark' | 'secondary' | 'secondary-light' | 'secondary-dark' | 'tertiary' | 'tertiary-light' | 'tertiary-dark' | 'error'} MeasureColor
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} MeasureOptions
|
|
14
|
+
* @property {string} markName - Mark name used as the start point for performance measurement
|
|
15
|
+
* @property {string} [measureName] - Measure name that will be displayed in the performance graph. If not provided, markName will be used by default
|
|
16
|
+
* @property {string} [category] - Category where the measure will be displayed int he performance graph
|
|
17
|
+
* @property {MeasureColor} [color] - Category where the measure will be displayed int he performance graph
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {object} PerformanceAPI
|
|
22
|
+
* @property {function(MeasureOptions): void} measure
|
|
23
|
+
* @property {function(string): string} mark
|
|
24
|
+
*/
|
|
25
|
+
var _default = {};
|
|
26
|
+
exports.default = _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.webPerformanceApi = void 0;
|
|
9
|
+
|
|
10
|
+
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Measure performances since the given markName
|
|
14
|
+
*
|
|
15
|
+
* @param {import('./types').MeasureOptions} options - Options for the measurement
|
|
16
|
+
*/
|
|
17
|
+
var measure = function measure(_ref) {
|
|
18
|
+
var measureName = _ref.measureName,
|
|
19
|
+
markName = _ref.markName,
|
|
20
|
+
category = _ref.category,
|
|
21
|
+
color = _ref.color;
|
|
22
|
+
var name = measureName !== null && measureName !== void 0 ? measureName : markName; // @ts-ignore
|
|
23
|
+
|
|
24
|
+
performance.measure(name, {
|
|
25
|
+
start: markName,
|
|
26
|
+
detail: {
|
|
27
|
+
devtools: {
|
|
28
|
+
track: category !== null && category !== void 0 ? category : 'CozyClient',
|
|
29
|
+
color: color !== null && color !== void 0 ? color : 'secondary'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Set a mark with the given name
|
|
36
|
+
*
|
|
37
|
+
* In order to ensure uniqueness of mark names,
|
|
38
|
+
* the given markName is prefixed with a unique id
|
|
39
|
+
*
|
|
40
|
+
* This method returns the computed mark name containing
|
|
41
|
+
* the unique id. This new ID should be used when
|
|
42
|
+
* calling `measure()`
|
|
43
|
+
*
|
|
44
|
+
* @param {string} markName - the name of the mark
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
var mark = function mark(markName) {
|
|
49
|
+
var uniqMarkName = "".concat((0, _uniqueId.default)(), " ").concat(markName);
|
|
50
|
+
performance.mark(uniqMarkName);
|
|
51
|
+
return uniqMarkName;
|
|
52
|
+
};
|
|
53
|
+
/** @type {import('./types').PerformanceAPI} */
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var webPerformanceApi = {
|
|
57
|
+
measure: measure,
|
|
58
|
+
mark: mark
|
|
59
|
+
};
|
|
60
|
+
exports.webPerformanceApi = webPerformanceApi;
|
package/dist/store/index.js
CHANGED
|
@@ -199,32 +199,57 @@ var initialState = {
|
|
|
199
199
|
queries: {}
|
|
200
200
|
};
|
|
201
201
|
|
|
202
|
-
var combinedReducer = function combinedReducer() {
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
var combinedReducer = function combinedReducer(performanceApi) {
|
|
203
|
+
return function () {
|
|
204
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
|
205
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
206
|
+
var markName = performanceApi.mark('combinedReducer');
|
|
205
207
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
if (action.type == RESET_ACTION_TYPE) {
|
|
209
|
+
performanceApi.measure({
|
|
210
|
+
markName: markName,
|
|
211
|
+
measureName: "".concat(markName, " reset"),
|
|
212
|
+
category: 'CozyClientStore'
|
|
213
|
+
});
|
|
214
|
+
return initialState;
|
|
215
|
+
}
|
|
209
216
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
217
|
+
if (!(0, _queries.isQueryAction)(action) && !(0, _mutations.isMutationAction)(action)) {
|
|
218
|
+
performanceApi.measure({
|
|
219
|
+
markName: markName,
|
|
220
|
+
measureName: "".concat(markName, " no query nor mutate action"),
|
|
221
|
+
category: 'CozyClientStore'
|
|
222
|
+
});
|
|
223
|
+
return state;
|
|
224
|
+
}
|
|
213
225
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
if (action.update) {
|
|
227
|
+
var proxy = new StoreProxy(state);
|
|
228
|
+
action.update(proxy, action.response);
|
|
229
|
+
var newState = {
|
|
230
|
+
documents: proxy.getState().documents,
|
|
231
|
+
queries: (0, _queries.default)(performanceApi, proxy.getState().queries, action, proxy.getState().documents)
|
|
232
|
+
};
|
|
233
|
+
performanceApi.measure({
|
|
234
|
+
markName: markName,
|
|
235
|
+
measureName: "".concat(markName, " update action"),
|
|
236
|
+
category: 'CozyClientStore'
|
|
237
|
+
});
|
|
238
|
+
return newState;
|
|
239
|
+
}
|
|
222
240
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
var nextDocuments = (0, _documents.default)(state.documents, action);
|
|
242
|
+
var haveDocumentsChanged = nextDocuments !== state.documents;
|
|
243
|
+
var queriesResult = {
|
|
244
|
+
documents: nextDocuments,
|
|
245
|
+
queries: (0, _queries.default)(performanceApi, state.queries, action, nextDocuments, haveDocumentsChanged)
|
|
246
|
+
};
|
|
247
|
+
performanceApi.measure({
|
|
248
|
+
markName: markName,
|
|
249
|
+
measureName: "".concat(markName, " queries"),
|
|
250
|
+
category: 'CozyClientStore'
|
|
251
|
+
});
|
|
252
|
+
return queriesResult;
|
|
228
253
|
};
|
|
229
254
|
};
|
|
230
255
|
|
|
@@ -236,9 +261,9 @@ var composedEnhancer = // @ts-ignore '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__' does
|
|
|
236
261
|
// see https://github.com/reduxjs/redux-devtools/tree/main/extension#11-basic-store
|
|
237
262
|
(0, _cozyFlags.default)('debug') && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || _redux.compose;
|
|
238
263
|
|
|
239
|
-
var createStore = function createStore() {
|
|
264
|
+
var createStore = function createStore(performanceApi) {
|
|
240
265
|
return (0, _redux.createStore)((0, _redux.combineReducers)({
|
|
241
|
-
cozy: combinedReducer
|
|
266
|
+
cozy: combinedReducer(performanceApi)
|
|
242
267
|
}), composedEnhancer((0, _redux.applyMiddleware)(_reduxThunk.default)));
|
|
243
268
|
};
|
|
244
269
|
|
package/dist/store/queries.js
CHANGED
|
@@ -167,6 +167,7 @@ var updateQueryDataFromResponse = function updateQueryDataFromResponse(queryStat
|
|
|
167
167
|
/**
|
|
168
168
|
* Reducer for a query slice
|
|
169
169
|
*
|
|
170
|
+
* @param {import('../performances/types').PerformanceAPI} performanceApi - The performance API that can be used to measure performances
|
|
170
171
|
* @param {import("../types").QueryState} state - Current state
|
|
171
172
|
* @param {any} action - Redux action
|
|
172
173
|
* @param {import("../types").DocumentsStateSlice} documents - Reference to the next documents slice
|
|
@@ -174,10 +175,10 @@ var updateQueryDataFromResponse = function updateQueryDataFromResponse(queryStat
|
|
|
174
175
|
*/
|
|
175
176
|
|
|
176
177
|
|
|
177
|
-
var query = function query() {
|
|
178
|
-
var state = arguments.length >
|
|
179
|
-
var action = arguments.length >
|
|
180
|
-
var documents = arguments.length >
|
|
178
|
+
var query = function query(performanceApi) {
|
|
179
|
+
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : queryInitialState;
|
|
180
|
+
var action = arguments.length > 2 ? arguments[2] : undefined;
|
|
181
|
+
var documents = arguments.length > 3 ? arguments[3] : undefined;
|
|
181
182
|
|
|
182
183
|
switch (action.type) {
|
|
183
184
|
case INIT_QUERY:
|
|
@@ -210,11 +211,17 @@ var query = function query() {
|
|
|
210
211
|
|
|
211
212
|
case RECEIVE_QUERY_RESULT:
|
|
212
213
|
{
|
|
214
|
+
var markName = performanceApi.mark('RECEIVE_QUERY_RESULT');
|
|
213
215
|
var response = action.response; // Data can be null when we get a 404 not found
|
|
214
216
|
// see Collection.get()
|
|
215
217
|
// but we still need to update the fetchStatus.
|
|
216
218
|
|
|
217
219
|
if (!response.data) {
|
|
220
|
+
performanceApi.measure({
|
|
221
|
+
markName: markName,
|
|
222
|
+
measureName: "".concat(markName, " with no data"),
|
|
223
|
+
category: 'CozyClientStore'
|
|
224
|
+
});
|
|
218
225
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
219
226
|
fetchStatus: 'loaded',
|
|
220
227
|
isFetching: action.backgroundFetching ? false : null,
|
|
@@ -235,6 +242,11 @@ var query = function query() {
|
|
|
235
242
|
});
|
|
236
243
|
|
|
237
244
|
if (!Array.isArray(response.data)) {
|
|
245
|
+
performanceApi.measure({
|
|
246
|
+
markName: markName,
|
|
247
|
+
measureName: "".concat(markName, " with object"),
|
|
248
|
+
category: 'CozyClientStore'
|
|
249
|
+
});
|
|
238
250
|
return _objectSpread(_objectSpread(_objectSpread({}, state), common), {}, {
|
|
239
251
|
hasMore: false,
|
|
240
252
|
count: 1,
|
|
@@ -245,6 +257,11 @@ var query = function query() {
|
|
|
245
257
|
var count = response.meta && response.meta.count ? response.meta.count : response.data.length;
|
|
246
258
|
|
|
247
259
|
if (action.backgroundFetching) {
|
|
260
|
+
performanceApi.measure({
|
|
261
|
+
markName: markName,
|
|
262
|
+
measureName: "".concat(markName, " with background fetching"),
|
|
263
|
+
category: 'CozyClientStore'
|
|
264
|
+
});
|
|
248
265
|
return _objectSpread(_objectSpread(_objectSpread({}, state), common), {}, {
|
|
249
266
|
bookmark: response.bookmark || null,
|
|
250
267
|
hasMore: response.next !== undefined ? response.next : state.hasMore,
|
|
@@ -258,6 +275,11 @@ var query = function query() {
|
|
|
258
275
|
count: count,
|
|
259
276
|
fetchedPagesCount: fetchedPagesCount
|
|
260
277
|
});
|
|
278
|
+
performanceApi.measure({
|
|
279
|
+
markName: markName,
|
|
280
|
+
measureName: "".concat(markName, " default"),
|
|
281
|
+
category: 'CozyClientStore'
|
|
282
|
+
});
|
|
261
283
|
return _objectSpread(_objectSpread(_objectSpread({}, state), common), {}, {
|
|
262
284
|
bookmark: response.bookmark || null,
|
|
263
285
|
hasMore: response.next !== undefined ? response.next : state.hasMore,
|
|
@@ -575,6 +597,7 @@ var manualQueryUpdater = function manualQueryUpdater(action, documents) {
|
|
|
575
597
|
};
|
|
576
598
|
};
|
|
577
599
|
/**
|
|
600
|
+
* @param {import('../performances/types').PerformanceAPI} performanceApi - The performance API that can be used to measure performances
|
|
578
601
|
* @param {import("../types").QueriesStateSlice} state - Redux slice containing all the query states indexed by name
|
|
579
602
|
* @param {object} action - Income redux action
|
|
580
603
|
* @param {import("../types").DocumentsStateSlice} documents - Reference to documents slice
|
|
@@ -583,14 +606,14 @@ var manualQueryUpdater = function manualQueryUpdater(action, documents) {
|
|
|
583
606
|
*/
|
|
584
607
|
|
|
585
608
|
|
|
586
|
-
var queries = function queries() {
|
|
587
|
-
var state = arguments.length >
|
|
588
|
-
var action = arguments.length >
|
|
589
|
-
var documents = arguments.length >
|
|
590
|
-
var haveDocumentsChanged = arguments.length >
|
|
609
|
+
var queries = function queries(performanceApi) {
|
|
610
|
+
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
611
|
+
var action = arguments.length > 2 ? arguments[2] : undefined;
|
|
612
|
+
var documents = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
613
|
+
var haveDocumentsChanged = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
591
614
|
|
|
592
615
|
if (action.type == INIT_QUERY) {
|
|
593
|
-
var newQueryState = query(state[action.queryId], action, documents); // Do not create new object unnecessarily
|
|
616
|
+
var newQueryState = query(performanceApi, state[action.queryId], action, documents); // Do not create new object unnecessarily
|
|
594
617
|
|
|
595
618
|
if (newQueryState === state[action.queryId]) {
|
|
596
619
|
return state;
|
|
@@ -603,7 +626,7 @@ var queries = function queries() {
|
|
|
603
626
|
var updater = autoQueryUpdater(action, documents);
|
|
604
627
|
return (0, _mapValues.default)(state, function (queryState) {
|
|
605
628
|
if (queryState.id == action.queryId) {
|
|
606
|
-
return query(queryState, action, documents);
|
|
629
|
+
return query(performanceApi, queryState, action, documents);
|
|
607
630
|
} else if (haveDocumentsChanged) {
|
|
608
631
|
return updater(queryState);
|
|
609
632
|
} else {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultPerformanceApi } from '../performances/defaultPerformanceApi'
|
|
1
2
|
import queries, {
|
|
2
3
|
initQuery,
|
|
3
4
|
receiveQueryResult,
|
|
@@ -19,7 +20,7 @@ describe('queries reducer', () => {
|
|
|
19
20
|
data: [TODO_1, TODO_2]
|
|
20
21
|
}
|
|
21
22
|
const applyAction = action => {
|
|
22
|
-
state = queries(state, action)
|
|
23
|
+
state = queries(defaultPerformanceApi, state, action)
|
|
23
24
|
}
|
|
24
25
|
beforeEach(() => {
|
|
25
26
|
state = {}
|
package/dist/store.spec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createStore, combineReducers } from 'redux'
|
|
2
2
|
import sortBy from 'lodash/sortBy'
|
|
3
3
|
|
|
4
|
+
import { defaultPerformanceApi } from './performances/defaultPerformanceApi'
|
|
4
5
|
import reducer, {
|
|
5
6
|
initQuery,
|
|
6
7
|
getCollectionFromState,
|
|
@@ -25,7 +26,9 @@ import {
|
|
|
25
26
|
describe('Store', () => {
|
|
26
27
|
let store
|
|
27
28
|
beforeEach(() => {
|
|
28
|
-
store = createStore(
|
|
29
|
+
store = createStore(
|
|
30
|
+
combineReducers({ cozy: reducer(defaultPerformanceApi) })
|
|
31
|
+
)
|
|
29
32
|
})
|
|
30
33
|
|
|
31
34
|
describe('documents state', () => {
|
package/dist/types.js
CHANGED
|
@@ -309,6 +309,7 @@ var _dsl = require("./queries/dsl");
|
|
|
309
309
|
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
310
310
|
* compatibility but will be set to true in the future.
|
|
311
311
|
* @property {boolean} [executeFromStore=false] - If set to true, the query will be run directly on the current store's state
|
|
312
|
+
* @property {boolean} [forceStack] - If set to true, the query will be executed through StackLink only even if there are other links available
|
|
312
313
|
*/
|
|
313
314
|
|
|
314
315
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "52.0.0",
|
|
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": "^
|
|
21
|
+
"cozy-stack-client": "^52.0.0",
|
|
22
22
|
"date-fns": "2.29.3",
|
|
23
23
|
"json-stable-stringify": "^1.0.1",
|
|
24
24
|
"lodash": "^4.17.13",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "5b59b97a76e9191e67f3c3ce885358f47df8a4e1"
|
|
76
76
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -76,6 +76,10 @@ export type ClientOptions = {
|
|
|
76
76
|
* - If set to false, the client will not instantiate a Redux store automatically. Use this if you want to merge cozy-client's store with your own redux store. See [here](https://docs.cozy.io/en/cozy-client/react-integration/#1b-use-your-own-redux-store) for more information.
|
|
77
77
|
*/
|
|
78
78
|
store?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* - The performance API that can be used to measure performances
|
|
81
|
+
*/
|
|
82
|
+
performanceApi?: import('./performances/types').PerformanceAPI;
|
|
79
83
|
};
|
|
80
84
|
/**
|
|
81
85
|
* @typedef {import("./types").CozyClientDocument} CozyClientDocument
|
|
@@ -99,6 +103,7 @@ export type ClientOptions = {
|
|
|
99
103
|
* @property {import("./types").AppMetadata} [appMetadata] - Metadata about the application that will be used in ensureCozyMetadata
|
|
100
104
|
* @property {import("./types").ClientCapabilities} [capabilities] - Capabilities sent by the stack
|
|
101
105
|
* @property {boolean} [store] - If set to false, the client will not instantiate a Redux store automatically. Use this if you want to merge cozy-client's store with your own redux store. See [here](https://docs.cozy.io/en/cozy-client/react-integration/#1b-use-your-own-redux-store) for more information.
|
|
106
|
+
* @property {import('./performances/types').PerformanceAPI} [performanceApi] - The performance API that can be used to measure performances
|
|
102
107
|
*/
|
|
103
108
|
/**
|
|
104
109
|
* Responsible for
|
|
@@ -189,6 +194,8 @@ declare class CozyClient {
|
|
|
189
194
|
* Cozy-Client will automatically call `this.login()` if provided with a token and an uri
|
|
190
195
|
*/
|
|
191
196
|
constructor(rawOptions?: ClientOptions);
|
|
197
|
+
/** @type {import('./performances/types').PerformanceAPI} */
|
|
198
|
+
performanceApi: import('./performances/types').PerformanceAPI;
|
|
192
199
|
appMetadata: import("./types").AppMetadata;
|
|
193
200
|
loginPromise: Promise<void>;
|
|
194
201
|
options: {
|
|
@@ -528,7 +535,7 @@ declare class CozyClient {
|
|
|
528
535
|
* @private
|
|
529
536
|
*/
|
|
530
537
|
private fetchRelationships;
|
|
531
|
-
requestMutation(definition: any): any;
|
|
538
|
+
requestMutation(definition: any, options: any): any;
|
|
532
539
|
getIncludesRelationships(queryDefinition: any): import("lodash").Dictionary<any>;
|
|
533
540
|
/**
|
|
534
541
|
* Returns documents with their relationships resolved according to their schema.
|
package/types/CozyLink.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export default class CozyLink {
|
|
|
4
4
|
* Request the given operation from the link
|
|
5
5
|
*
|
|
6
6
|
* @param {any} operation - The operation to request
|
|
7
|
+
* @param {any} options - The request options
|
|
7
8
|
* @param {any} result - The result from the previous request of the chain
|
|
8
9
|
* @param {any} forward - The next request of the chain
|
|
9
10
|
* @returns {Promise<any>}
|
|
10
11
|
*/
|
|
11
|
-
request(operation: any, result: any, forward: any): Promise<any>;
|
|
12
|
+
request(operation: any, options: any, result: any, forward: any): Promise<any>;
|
|
12
13
|
/**
|
|
13
14
|
* Persist the given data into the links storage
|
|
14
15
|
*
|
package/types/StackLink.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export function transformBulkDocsResponse(bulkResponse: import("./types").CouchD
|
|
|
6
6
|
* @property {object} [stackClient] - A StackClient
|
|
7
7
|
* @property {object} [client] - A StackClient (deprecated)
|
|
8
8
|
* @property {import('cozy-pouch-link/dist/types').LinkPlatform} [platform] - Platform specific adapters and methods
|
|
9
|
+
* @property {import('./performances/types').PerformanceAPI} [performanceApi] - The performance API that can be used to measure performances
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
12
|
* Transfers queries and mutations to a remote stack
|
|
@@ -14,9 +15,11 @@ export default class StackLink extends CozyLink {
|
|
|
14
15
|
/**
|
|
15
16
|
* @param {StackLinkOptions} [options] - Options
|
|
16
17
|
*/
|
|
17
|
-
constructor({ client, stackClient, platform }?: StackLinkOptions);
|
|
18
|
+
constructor({ client, stackClient, platform, performanceApi }?: StackLinkOptions);
|
|
18
19
|
stackClient: any;
|
|
19
20
|
isOnline: any;
|
|
21
|
+
/** @type {import('./performances/types').PerformanceAPI} */
|
|
22
|
+
performanceApi: import('./performances/types').PerformanceAPI;
|
|
20
23
|
registerClient(client: any): void;
|
|
21
24
|
/**
|
|
22
25
|
*
|
|
@@ -24,7 +27,7 @@ export default class StackLink extends CozyLink {
|
|
|
24
27
|
* @returns {Promise<import("./types").ClientResponse>}
|
|
25
28
|
*/
|
|
26
29
|
executeQuery(query: QueryDefinition): Promise<import("./types").ClientResponse>;
|
|
27
|
-
executeMutation(mutation: any, result: any, forward: any): Promise<any>;
|
|
30
|
+
executeMutation(mutation: any, options: any, result: any, forward: any): Promise<any>;
|
|
28
31
|
}
|
|
29
32
|
export type StackLinkOptions = {
|
|
30
33
|
/**
|
|
@@ -39,6 +42,10 @@ export type StackLinkOptions = {
|
|
|
39
42
|
* - Platform specific adapters and methods
|
|
40
43
|
*/
|
|
41
44
|
platform?: any;
|
|
45
|
+
/**
|
|
46
|
+
* - The performance API that can be used to measure performances
|
|
47
|
+
*/
|
|
48
|
+
performanceApi?: import('./performances/types').PerformanceAPI;
|
|
42
49
|
};
|
|
43
50
|
import CozyLink from "./CozyLink";
|
|
44
51
|
import { QueryDefinition } from "./queries/dsl";
|
package/types/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { default as fetchPolicies } from "./policies";
|
|
|
13
13
|
export * from "./mock";
|
|
14
14
|
export * from "./hooks";
|
|
15
15
|
export { BulkEditError } from "./errors";
|
|
16
|
+
export { webPerformanceApi } from "./performances/webPerformanceApi";
|
|
17
|
+
export { defaultPerformanceApi } from "./performances/defaultPerformanceApi";
|
|
16
18
|
import * as manifest from "./models/manifest";
|
|
17
19
|
import * as models from "./models";
|
|
18
20
|
export { manifest, models };
|
package/types/index.node.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from "./mock";
|
|
|
10
10
|
export * from "./cli";
|
|
11
11
|
export { BulkEditError } from "./errors";
|
|
12
12
|
export { default as fetchPolicies } from "./policies";
|
|
13
|
+
export { webPerformanceApi } from "./performances/webPerformanceApi";
|
|
14
|
+
export { defaultPerformanceApi } from "./performances/defaultPerformanceApi";
|
|
13
15
|
import * as manifest from "./models/manifest";
|
|
14
16
|
import * as models from "./models";
|
|
15
17
|
export { manifest, models };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare var _default: {};
|
|
2
|
+
export default _default;
|
|
3
|
+
export type MeasureColor = "error" | "primary" | "primary-light" | "primary-dark" | "secondary" | "secondary-light" | "secondary-dark" | "tertiary" | "tertiary-light" | "tertiary-dark";
|
|
4
|
+
export type MeasureOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* - Mark name used as the start point for performance measurement
|
|
7
|
+
*/
|
|
8
|
+
markName: string;
|
|
9
|
+
/**
|
|
10
|
+
* - Measure name that will be displayed in the performance graph. If not provided, markName will be used by default
|
|
11
|
+
*/
|
|
12
|
+
measureName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* - Category where the measure will be displayed int he performance graph
|
|
15
|
+
*/
|
|
16
|
+
category?: string;
|
|
17
|
+
/**
|
|
18
|
+
* - Category where the measure will be displayed int he performance graph
|
|
19
|
+
*/
|
|
20
|
+
color?: MeasureColor;
|
|
21
|
+
};
|
|
22
|
+
export type PerformanceAPI = {
|
|
23
|
+
measure: (arg0: MeasureOptions) => void;
|
|
24
|
+
mark: (arg0: string) => string;
|
|
25
|
+
};
|