cozy-client 26.0.2 → 27.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/CHANGELOG.md +38 -0
- package/dist/CozyClient.js +20 -16
- package/dist/CozyClient.spec.js +16 -3
- package/dist/queries/dsl.js +4 -4
- package/package.json +3 -3
- package/types/CozyClient.d.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [27.2.0](https://github.com/cozy/cozy-client/compare/v27.1.0...v27.2.0) (2021-11-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Be more explicit on query warning messages ([8d9b896](https://github.com/cozy/cozy-client/commit/8d9b896693f94898e610a79da69dda6bc0ad6f0a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [27.1.0](https://github.com/cozy/cozy-client/compare/v27.0.1...v27.1.0) (2021-11-04)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package cozy-client
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [27.0.1](https://github.com/cozy/cozy-client/compare/v27.0.0...v27.0.1) (2021-11-04)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* Build new OAuth client from old OAuth client ([a8ecfd0](https://github.com/cozy/cozy-client/commit/a8ecfd0344d86ba7c45e2589442bb836ba274a89))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [27.0.0](https://github.com/cozy/cozy-client/compare/v26.0.2...v27.0.0) (2021-11-03)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package cozy-client
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
6
44
|
## [26.0.2](https://github.com/cozy/cozy-client/compare/v26.0.1...v26.0.2) (2021-11-01)
|
|
7
45
|
|
|
8
46
|
|
package/dist/CozyClient.js
CHANGED
|
@@ -360,6 +360,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
360
360
|
* a client with a cookie-based instance of cozy-client-js.
|
|
361
361
|
*
|
|
362
362
|
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
363
|
+
* @param {object} options - CozyStackClient options
|
|
363
364
|
* @returns {CozyClient}
|
|
364
365
|
*/
|
|
365
366
|
|
|
@@ -699,7 +700,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
699
700
|
}, {
|
|
700
701
|
key: "get",
|
|
701
702
|
value: function get(doctype, id) {
|
|
702
|
-
console.warn(
|
|
703
|
+
console.warn("client.get(".concat(doctype, ", id) is deprecated, please use Q(").concat(doctype, ").getById(id) to build the same query."));
|
|
703
704
|
return new _dsl.QueryDefinition({
|
|
704
705
|
doctype: doctype,
|
|
705
706
|
id: id
|
|
@@ -2276,7 +2277,8 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2276
2277
|
*
|
|
2277
2278
|
* Warning: unlike other instantiators, this one needs to be awaited.
|
|
2278
2279
|
*
|
|
2279
|
-
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
2280
|
+
* @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
|
|
2281
|
+
* @param {object} options - CozyStackClient options
|
|
2280
2282
|
* @returns {Promise<CozyClient>} An instance of a client, configured from the old client
|
|
2281
2283
|
*/
|
|
2282
2284
|
|
|
@@ -2284,30 +2286,32 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2284
2286
|
key: "fromOldOAuthClient",
|
|
2285
2287
|
value: function () {
|
|
2286
2288
|
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(oldClient, options) {
|
|
2287
|
-
var
|
|
2289
|
+
var credentials, oauthOptions;
|
|
2288
2290
|
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
2289
2291
|
while (1) {
|
|
2290
2292
|
switch (_context17.prev = _context17.next) {
|
|
2291
2293
|
case 0:
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
if (!hasOauthCreds) {
|
|
2294
|
+
if (!oldClient._oauth) {
|
|
2295
2295
|
_context17.next = 8;
|
|
2296
2296
|
break;
|
|
2297
2297
|
}
|
|
2298
2298
|
|
|
2299
|
-
_context17.next =
|
|
2300
|
-
return oldClient.
|
|
2299
|
+
_context17.next = 3;
|
|
2300
|
+
return oldClient.authorize();
|
|
2301
2301
|
|
|
2302
|
-
case
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
token: token
|
|
2307
|
-
|
|
2302
|
+
case 3:
|
|
2303
|
+
credentials = _context17.sent;
|
|
2304
|
+
oauthOptions = {
|
|
2305
|
+
oauth: credentials.client,
|
|
2306
|
+
token: credentials.token,
|
|
2307
|
+
scope: credentials.token.scope
|
|
2308
|
+
};
|
|
2309
|
+
return _context17.abrupt("return", new CozyClient(_objectSpread(_objectSpread({
|
|
2310
|
+
uri: oldClient._url
|
|
2311
|
+
}, oauthOptions), options)));
|
|
2308
2312
|
|
|
2309
2313
|
case 8:
|
|
2310
|
-
throw new Error('
|
|
2314
|
+
throw new Error('Cannot instantiate a new client: old client is not an OAuth client. CozyClient.fromOldClient might be more suitable.');
|
|
2311
2315
|
|
|
2312
2316
|
case 9:
|
|
2313
2317
|
case "end":
|
|
@@ -2411,7 +2415,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2411
2415
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2412
2416
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2413
2417
|
|
|
2414
|
-
CozyClient.version = "
|
|
2418
|
+
CozyClient.version = "27.2.0";
|
|
2415
2419
|
|
|
2416
2420
|
_microee.default.mixin(CozyClient);
|
|
2417
2421
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -143,17 +143,30 @@ describe('CozyClient initialization', () => {
|
|
|
143
143
|
it('can be instantiated from an oauth-based old client', async () => {
|
|
144
144
|
// Not using a real cozy-client-js here not to have to add it as a dep
|
|
145
145
|
const url = 'https://testcozy.mycozy.cloud'
|
|
146
|
-
const
|
|
146
|
+
const oauth = {
|
|
147
|
+
clientID: 'my-client'
|
|
148
|
+
// ... other OAuth client attributes
|
|
149
|
+
}
|
|
150
|
+
const token = {
|
|
151
|
+
tokenType: 'bearer',
|
|
152
|
+
accessToken: 'access-token',
|
|
153
|
+
refreshToken: 'refresh-token',
|
|
154
|
+
scope: ['io.cozy.files']
|
|
155
|
+
}
|
|
147
156
|
const oldClient = {
|
|
148
157
|
_url: url,
|
|
149
158
|
_oauth: true,
|
|
150
|
-
|
|
159
|
+
authorize: () => ({
|
|
160
|
+
client: oauth,
|
|
151
161
|
token
|
|
152
162
|
})
|
|
153
163
|
}
|
|
154
164
|
const client = await CozyClient.fromOldOAuthClient(oldClient)
|
|
165
|
+
console.log({ stackClient: client.stackClient })
|
|
155
166
|
expect(client.stackClient.uri).toBe(url)
|
|
156
|
-
expect(client.stackClient.
|
|
167
|
+
expect(client.stackClient.oauthOptions.clientID).toBe(oauth.clientID)
|
|
168
|
+
expect(client.stackClient.token.accessToken).toBe(token.accessToken)
|
|
169
|
+
expect(client.stackClient.scope).toBe(token.scope)
|
|
157
170
|
})
|
|
158
171
|
|
|
159
172
|
it('can be instantiated from dataset injected by the Stack in DOM', async () => {
|
package/dist/queries/dsl.js
CHANGED
|
@@ -120,13 +120,13 @@ var QueryDefinition = /*#__PURE__*/function () {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
if (_sort.length > fieldsToIndex.length) {
|
|
123
|
-
console.warn(
|
|
123
|
+
console.warn("You should not sort on non-indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex));
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
for (var i = 0; i < _sort.length; i++) {
|
|
128
128
|
if (Object.keys(_sort[i])[0] !== fieldsToIndex[i]) {
|
|
129
|
-
console.warn(
|
|
129
|
+
console.warn("The sort order should be the same than the indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex, "\n"));
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -146,13 +146,13 @@ var QueryDefinition = /*#__PURE__*/function () {
|
|
|
146
146
|
var hasExistsFalse = (0, _findKey.default)(selector, ['$exists', false]);
|
|
147
147
|
|
|
148
148
|
if (hasExistsFalse) {
|
|
149
|
-
console.warn(
|
|
149
|
+
console.warn("The \"$exists: false\" predicate should be defined as a partial index for better performance.\n\n Selector: ".concat(selector));
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
var hasNe = (0, _findKey.default)(selector, '$ne');
|
|
153
153
|
|
|
154
154
|
if (hasNe) {
|
|
155
|
-
console.info(
|
|
155
|
+
console.info("The use of the $ne operator is more efficient with a partial index.\n\n Selector: ".concat(selector));
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cozy-device-helper": "^1.12.0",
|
|
22
22
|
"cozy-flags": "2.7.1",
|
|
23
23
|
"cozy-logger": "^1.6.0",
|
|
24
|
-
"cozy-stack-client": "^
|
|
24
|
+
"cozy-stack-client": "^27.1.0",
|
|
25
25
|
"json-stable-stringify": "^1.0.1",
|
|
26
26
|
"lodash": "^4.17.13",
|
|
27
27
|
"microee": "^0.0.6",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"react-native-inappbrowser-reborn": "^3.5.1"
|
|
69
69
|
},
|
|
70
70
|
"sideEffects": false,
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "3615a75a501a937ae3c73ada67d00b33d2ed7e62"
|
|
72
72
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -61,19 +61,21 @@ declare class CozyClient {
|
|
|
61
61
|
* a client with a cookie-based instance of cozy-client-js.
|
|
62
62
|
*
|
|
63
63
|
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
64
|
+
* @param {object} options - CozyStackClient options
|
|
64
65
|
* @returns {CozyClient}
|
|
65
66
|
*/
|
|
66
|
-
static fromOldClient(oldClient: OldCozyClient, options:
|
|
67
|
+
static fromOldClient(oldClient: OldCozyClient, options: object): CozyClient;
|
|
67
68
|
/**
|
|
68
69
|
* To help with the transition from cozy-client-js to cozy-client, it is possible to instantiate
|
|
69
70
|
* a client with an OAuth-based instance of cozy-client-js.
|
|
70
71
|
*
|
|
71
72
|
* Warning: unlike other instantiators, this one needs to be awaited.
|
|
72
73
|
*
|
|
73
|
-
* @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
|
|
74
|
+
* @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
|
|
75
|
+
* @param {object} options - CozyStackClient options
|
|
74
76
|
* @returns {Promise<CozyClient>} An instance of a client, configured from the old client
|
|
75
77
|
*/
|
|
76
|
-
static fromOldOAuthClient(oldClient: OldCozyClient, options:
|
|
78
|
+
static fromOldOAuthClient(oldClient: OldCozyClient, options: object): Promise<CozyClient>;
|
|
77
79
|
/**
|
|
78
80
|
* In konnector/service context, CozyClient can be instantiated from
|
|
79
81
|
* environment variables
|