cozy-pouch-link 59.4.0 → 60.1.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.
@@ -1078,12 +1078,12 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
1078
1078
  key: "executeQuery",
1079
1079
  value: function () {
1080
1080
  var _executeQuery = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(_ref5) {
1081
- var doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter, engine, res, findSelector, findOpts;
1081
+ var doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter, sharingId, engine, res, findSelector, findOpts;
1082
1082
  return _regenerator.default.wrap(function _callee11$(_context11) {
1083
1083
  while (1) {
1084
1084
  switch (_context11.prev = _context11.next) {
1085
1085
  case 0:
1086
- doctype = _ref5.doctype, selector = _ref5.selector, sort = _ref5.sort, fields = _ref5.fields, limit = _ref5.limit, id = _ref5.id, ids = _ref5.ids, skip = _ref5.skip, indexedFields = _ref5.indexedFields, partialFilter = _ref5.partialFilter;
1086
+ doctype = _ref5.doctype, selector = _ref5.selector, sort = _ref5.sort, fields = _ref5.fields, limit = _ref5.limit, id = _ref5.id, ids = _ref5.ids, skip = _ref5.skip, indexedFields = _ref5.indexedFields, partialFilter = _ref5.partialFilter, sharingId = _ref5.sharingId;
1087
1087
  engine = this.getQueryEngineFromDoctype(doctype);
1088
1088
 
1089
1089
  if (!id) {
@@ -1135,7 +1135,9 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
1135
1135
  selector: selector,
1136
1136
  sort: sort,
1137
1137
  indexedFields: indexedFields,
1138
- partialFilter: partialFilter
1138
+ partialFilter: partialFilter,
1139
+ doctype: doctype,
1140
+ sharingId: sharingId
1139
1141
  });
1140
1142
  findOpts = {
1141
1143
  sort: sort,
package/dist/helpers.js CHANGED
@@ -74,7 +74,9 @@ helpers.normalizeFindSelector = function (_ref2) {
74
74
  var selector = _ref2.selector,
75
75
  sort = _ref2.sort,
76
76
  indexedFields = _ref2.indexedFields,
77
- partialFilter = _ref2.partialFilter;
77
+ partialFilter = _ref2.partialFilter,
78
+ doctype = _ref2.doctype,
79
+ sharingId = _ref2.sharingId;
78
80
  var findSelector = selector || {};
79
81
 
80
82
  if (indexedFields) {
@@ -131,6 +133,12 @@ helpers.normalizeFindSelector = function (_ref2) {
131
133
  }
132
134
  }
133
135
 
136
+ if (sharingId && doctype === 'io.cozy.files') {
137
+ // The sharingId is currently only used for io.cozy.files and saved as 'driveId'
138
+ // by the stack response
139
+ findSelector['driveId'] = sharingId;
140
+ }
141
+
134
142
  var mergedSelector = partialFilter ? (0, _merge.default)(_objectSpread({}, findSelector), partialFilter) : findSelector;
135
143
  return Object.keys(mergedSelector).length > 0 ? mergedSelector : {
136
144
  _id: {
@@ -99,5 +99,19 @@ describe('Helpers', () => {
99
99
  SOME_INDEXED_FIELD: { $gt: null }
100
100
  })
101
101
  })
102
+
103
+ it('should add driveId to selector when sharingId is provided for io.cozy.files', () => {
104
+ const selector = { dir_id: '123' }
105
+
106
+ const findSelector = normalizeFindSelector({
107
+ doctype: 'io.cozy.files',
108
+ selector,
109
+ sharingId: 'sharingId'
110
+ })
111
+ expect(findSelector).toStrictEqual({
112
+ dir_id: '123',
113
+ driveId: 'sharingId'
114
+ })
115
+ })
102
116
  })
103
117
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-pouch-link",
3
- "version": "59.4.0",
3
+ "version": "60.1.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "types/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "url": "git+https://github.com/cozy/cozy-client.git"
14
14
  },
15
15
  "dependencies": {
16
- "cozy-client": "^59.4.0",
16
+ "cozy-client": "^60.1.0",
17
17
  "pouchdb-browser": "^7.2.2",
18
18
  "pouchdb-find": "^7.2.2"
19
19
  },
@@ -41,5 +41,5 @@
41
41
  "typecheck": "tsc -p tsconfig.json"
42
42
  },
43
43
  "sideEffects": false,
44
- "gitHead": "480639829db6f746159c9fd3fba3e69fcbb0cb29"
44
+ "gitHead": "78342f53c89c0c28a1559e6f0224249f4713c47b"
45
45
  }
@@ -215,7 +215,7 @@ declare class PouchLink extends CozyLink {
215
215
  */
216
216
  needsToWaitWarmup(doctype: string): Promise<boolean>;
217
217
  hasIndex(name: any): boolean;
218
- executeQuery({ doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter }: {
218
+ executeQuery({ doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter, sharingId }: {
219
219
  doctype: any;
220
220
  selector: any;
221
221
  sort: any;
@@ -226,6 +226,7 @@ declare class PouchLink extends CozyLink {
226
226
  skip: any;
227
227
  indexedFields: any;
228
228
  partialFilter: any;
229
+ sharingId: any;
229
230
  }): Promise<any>;
230
231
  executeMutation(mutation: any, options: any, result: any, forward: any): Promise<any>;
231
232
  createDocument(mutation: any): Promise<any>;
@@ -5,10 +5,12 @@ declare namespace helpers {
5
5
  function isDesignDocument(doc: any): boolean;
6
6
  function isDeletedDocument(doc: any): any;
7
7
  function insertBulkDocs(db: any, docs: any): Promise<any>;
8
- function normalizeFindSelector({ selector, sort, indexedFields, partialFilter }: {
8
+ function normalizeFindSelector({ selector, sort, indexedFields, partialFilter, doctype, sharingId }: {
9
9
  selector: any;
10
10
  sort: any;
11
11
  indexedFields: any;
12
12
  partialFilter: any;
13
+ doctype: any;
14
+ sharingId: any;
13
15
  }): any;
14
16
  }