cozy-client 59.1.0 → 59.1.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.
@@ -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.1.0";
3267
+ CozyClient.version = "59.1.1";
3268
3268
 
3269
3269
  _microee.default.mixin(CozyClient);
3270
3270
 
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "59.1.0",
3
+ "version": "59.1.1",
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": "b1b84902b2139a368f54b6ffaee654fe6cb1b03e"
77
+ "gitHead": "b5f239115811ed4f4bc9f064da17377ee5c48dd6"
78
78
  }
@@ -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;