cozy-client 59.1.0 → 59.2.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 +1 -1
- package/dist/store/queries.js +5 -1
- package/dist/store/queries.spec.js +27 -1
- package/dist/utils.js +16 -2
- package/package.json +2 -2
- package/types/store/queries.d.ts +1 -0
- package/types/utils.d.ts +1 -0
package/dist/CozyClient.js
CHANGED
|
@@ -3264,7 +3264,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3264
3264
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3265
3265
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3266
3266
|
|
|
3267
|
-
CozyClient.version = "59.
|
|
3267
|
+
CozyClient.version = "59.2.0";
|
|
3268
3268
|
|
|
3269
3269
|
_microee.default.mixin(CozyClient);
|
|
3270
3270
|
|
package/dist/store/queries.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.QueryIDGenerator = exports.getQueryFromSlice = exports.resetQuery = exports.receiveQueryError = exports.receiveQueryResult = exports.loadQuery = exports.initQuery = exports.default = exports.updateData = exports.makeSorterFromDefinition = exports.executeQueryFromState = exports.mergeSelectorAndPartialIndex = exports.convert$gtNullSelectors = exports.sortAndLimitDocsIds = exports.isReceivingData = exports.isQueryAction = void 0;
|
|
8
|
+
exports.QueryIDGenerator = exports.getQueryFromSlice = exports.mapIdsToDocuments = exports.resetQuery = exports.receiveQueryError = exports.receiveQueryResult = exports.loadQuery = exports.initQuery = exports.default = exports.updateData = exports.makeSorterFromDefinition = exports.executeQueryFromState = exports.mergeSelectorAndPartialIndex = exports.convert$gtNullSelectors = exports.sortAndLimitDocsIds = exports.isReceivingData = exports.isQueryAction = void 0;
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|
|
@@ -760,9 +760,13 @@ exports.resetQuery = resetQuery;
|
|
|
760
760
|
var mapIdsToDocuments = function mapIdsToDocuments(documents, doctype, ids) {
|
|
761
761
|
return ids.map(function (id) {
|
|
762
762
|
return (0, _documents.getDocumentFromSlice)(documents, doctype, id);
|
|
763
|
+
}).filter(function (doc) {
|
|
764
|
+
return !!doc;
|
|
763
765
|
});
|
|
764
766
|
};
|
|
765
767
|
|
|
768
|
+
exports.mapIdsToDocuments = mapIdsToDocuments;
|
|
769
|
+
|
|
766
770
|
var getQueryFromSlice = function getQueryFromSlice(state, queryId, documents) {
|
|
767
771
|
if (!state || !state[queryId]) {
|
|
768
772
|
return _objectSpread(_objectSpread({}, queryInitialState), {}, {
|
|
@@ -9,7 +9,8 @@ import queries, {
|
|
|
9
9
|
loadQuery,
|
|
10
10
|
receiveQueryError,
|
|
11
11
|
updateData,
|
|
12
|
-
executeQueryFromState
|
|
12
|
+
executeQueryFromState,
|
|
13
|
+
mapIdsToDocuments
|
|
13
14
|
} from './queries'
|
|
14
15
|
import { Q } from '../queries/dsl'
|
|
15
16
|
import { TODO_1, TODO_2, TODO_3 } from '../__tests__/fixtures'
|
|
@@ -829,3 +830,28 @@ describe('execute query from state', () => {
|
|
|
829
830
|
expect(res2.data[2]._id).toEqual('123')
|
|
830
831
|
})
|
|
831
832
|
})
|
|
833
|
+
|
|
834
|
+
describe('mapIdsToDocuments', () => {
|
|
835
|
+
const documents = {
|
|
836
|
+
'io.cozy.files': {
|
|
837
|
+
'123': { _id: '123', _type: 'io.cozy.files' },
|
|
838
|
+
'456': { _id: '456', _type: 'io.cozy.files' },
|
|
839
|
+
'789': { _id: '789', _type: 'io.cozy.files' }
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
it('should return the correct docs', () => {
|
|
844
|
+
const ids = ['123', '789']
|
|
845
|
+
const res = mapIdsToDocuments(documents, 'io.cozy.files', ids)
|
|
846
|
+
expect(res).toEqual([
|
|
847
|
+
{ _id: '123', _type: 'io.cozy.files' },
|
|
848
|
+
{ _id: '789', _type: 'io.cozy.files' }
|
|
849
|
+
])
|
|
850
|
+
})
|
|
851
|
+
|
|
852
|
+
it('should not return missing docs', () => {
|
|
853
|
+
const ids = ['123', 'ghostid']
|
|
854
|
+
const res = mapIdsToDocuments(documents, 'io.cozy.files', ids)
|
|
855
|
+
expect(res).toEqual([{ _id: '123', _type: 'io.cozy.files' }])
|
|
856
|
+
})
|
|
857
|
+
})
|
package/dist/utils.js
CHANGED
|
@@ -5,7 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.isReactNativeOfflineError = exports.hasQueriesBeenLoaded = exports.isQueriesLoading = exports.hasQueryBeenLoaded = exports.isQueryLoading = exports.cancelable = void 0;
|
|
8
|
+
exports.isDebug = exports.isReactNativeOfflineError = exports.hasQueriesBeenLoaded = exports.isQueriesLoading = exports.hasQueryBeenLoaded = exports.isQueryLoading = exports.cancelable = void 0;
|
|
9
|
+
|
|
10
|
+
var _cozyFlags = _interopRequireDefault(require("cozy-flags"));
|
|
9
11
|
|
|
10
12
|
var _logger = _interopRequireDefault(require("./logger"));
|
|
11
13
|
|
|
@@ -104,5 +106,17 @@ var isReactNativeOfflineError = function isReactNativeOfflineError(err) {
|
|
|
104
106
|
// Network errors on a browser would produce another error.message
|
|
105
107
|
return err.message === 'Network request failed';
|
|
106
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* Check if the instance has a debug flag set to true
|
|
111
|
+
*
|
|
112
|
+
* @returns {boolean} Whether or not the instance is in debug mode
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
exports.isReactNativeOfflineError = isReactNativeOfflineError;
|
|
117
|
+
|
|
118
|
+
var isDebug = function isDebug() {
|
|
119
|
+
return Boolean((0, _cozyFlags.default)('debug'));
|
|
120
|
+
};
|
|
107
121
|
|
|
108
|
-
exports.
|
|
122
|
+
exports.isDebug = isDebug;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "59.
|
|
3
|
+
"version": "59.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"react-native-ios11-devicecheck": "^0.0.3"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "be4082e8c9bb534dbd6ab16cdc0b1ad9ea99693d"
|
|
78
78
|
}
|
package/types/store/queries.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export function loadQuery(queryId: string, options?: import("../types").QueryOpt
|
|
|
15
15
|
export function receiveQueryResult(queryId: string, response: object, options?: import("../types").QueryOptions): object;
|
|
16
16
|
export function receiveQueryError(queryId: string, error: object, options?: import("../types").QueryOptions): object;
|
|
17
17
|
export function resetQuery(queryId: string): object;
|
|
18
|
+
export function mapIdsToDocuments(documents: any, doctype: any, ids: any): any;
|
|
18
19
|
export function getQueryFromSlice(state: any, queryId: any, documents: any): any;
|
|
19
20
|
export class QueryIDGenerator {
|
|
20
21
|
idCounter: number;
|
package/types/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export function hasQueryBeenLoaded(col: any): any;
|
|
|
3
3
|
export function isQueriesLoading(queriesResults: any): boolean;
|
|
4
4
|
export function hasQueriesBeenLoaded(queriesResults: any): boolean;
|
|
5
5
|
export function isReactNativeOfflineError(err: Error): boolean;
|
|
6
|
+
export function isDebug(): boolean;
|
|
6
7
|
export type CancelablePromise = Promise<any>;
|
|
7
8
|
/**
|
|
8
9
|
* @typedef {Promise} CancelablePromise
|