cozy-client 45.15.0 → 46.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.
@@ -2705,7 +2705,7 @@ var CozyClient = /*#__PURE__*/function () {
2705
2705
  CozyClient.hooks = CozyClient.hooks || {};
2706
2706
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2707
2707
 
2708
- CozyClient.version = "45.15.0";
2708
+ CozyClient.version = "46.0.0";
2709
2709
 
2710
2710
  _microee.default.mixin(CozyClient);
2711
2711
 
@@ -156,6 +156,15 @@ var QueryDefinition = /*#__PURE__*/function () {
156
156
  if (hasNe) {
157
157
  _logger.default.info("The use of the $ne operator is more efficient with a partial index.\n\n Selector: ".concat(JSON.stringify(selector)));
158
158
  }
159
+
160
+ var nestedArrayKey = (0, _findKey.default)(selector, function (value) {
161
+ return Array.isArray(value);
162
+ });
163
+ var hasNestedArrayWithoutOperator = nestedArrayKey && !nestedArrayKey.startsWith('$');
164
+
165
+ if (hasNestedArrayWithoutOperator) {
166
+ throw new Error("You pass ".concat(JSON.stringify(selector), ", this is a valid mango operation, \n\n but sift doesn't support it so CozyClient can not evaluate \n\n the request in memory. You must use a MongoDB operator \n\n like $in or $or operator instead, preferably in a partial index, \n\n to avoid costly full-scan"));
167
+ }
159
168
  }
160
169
  /**
161
170
  * Check if the selected fields are all included in the selectors
@@ -108,7 +108,18 @@ describe('QueryDefinition', () => {
108
108
  Q('io.cozy.files').where({ _id: { $ne: 'io.cozy.root-id' } })
109
109
  expect(logger.info).toHaveBeenCalledTimes(1)
110
110
  })
111
-
111
+ it('should throw when using a selector with an array without an $operator', () => {
112
+ const query = () =>
113
+ Q('io.cozy.files').where({ worker: ['worker1', 'worker2'] })
114
+ expect(() => query()).toThrow()
115
+ })
116
+ it('should not throw an error when we make a selector on multiple value with a mango operator', () => {
117
+ const query = () =>
118
+ Q('io.cozy.files').where({
119
+ worker: { $in: ['konnector', 'client'] }
120
+ })
121
+ expect(() => query()).not.toThrow()
122
+ })
112
123
  it('should throw an error when there is a select without all the fields in selector', () => {
113
124
  const query = () =>
114
125
  Q('io.cozy.files')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "45.15.0",
3
+ "version": "46.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": "^45.13.0",
21
+ "cozy-stack-client": "^46.0.0",
22
22
  "date-fns": "2.29.3",
23
23
  "json-stable-stringify": "^1.0.1",
24
24
  "lodash": "^4.17.13",
@@ -75,5 +75,5 @@
75
75
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
76
76
  },
77
77
  "sideEffects": false,
78
- "gitHead": "3eb9be9c7a7efaade9593fe809ff24f02780a5b1"
78
+ "gitHead": "c7691dddf7e5e737c5273344b0fb863ae7948194"
79
79
  }