diff --git a/docs/api/cozy-client/README.md b/docs/api/cozy-client/README.md index 7c79dc26a3..24de4cada6 100644 --- a/docs/api/cozy-client/README.md +++ b/docs/api/cozy-client/README.md @@ -61,7 +61,7 @@ cozy-client *Defined in* -[packages/cozy-client/src/queries/dsl.js:528](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L528) +[packages/cozy-client/src/queries/dsl.js:541](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L541) *** @@ -87,7 +87,7 @@ cozy-client *Defined in* -[packages/cozy-client/src/queries/dsl.js:514](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L514) +[packages/cozy-client/src/queries/dsl.js:527](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L527) *** @@ -197,7 +197,7 @@ query definitions. *Defined in* -[packages/cozy-client/src/queries/dsl.js:394](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L394) +[packages/cozy-client/src/queries/dsl.js:407](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L407) *** @@ -569,7 +569,7 @@ Generated URL *Defined in* -[packages/cozy-client/src/queries/dsl.js:486](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L486) +[packages/cozy-client/src/queries/dsl.js:499](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L499) *** diff --git a/docs/api/cozy-client/classes/CozyClient.md b/docs/api/cozy-client/classes/CozyClient.md index cdb1e77c0f..70796781a4 100644 --- a/docs/api/cozy-client/classes/CozyClient.md +++ b/docs/api/cozy-client/classes/CozyClient.md @@ -83,7 +83,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1947](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1947) +[packages/cozy-client/src/CozyClient.js:1881](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1881) *** @@ -93,7 +93,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1807](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1807) +[packages/cozy-client/src/CozyClient.js:1741](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1741) *** @@ -143,7 +143,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1943](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1943) +[packages/cozy-client/src/CozyClient.js:1877](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1877) *** @@ -230,7 +230,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1782](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1782) +[packages/cozy-client/src/CozyClient.js:1716](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1716) *** @@ -240,7 +240,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1712](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1712) +[packages/cozy-client/src/CozyClient.js:1646](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1646) *** @@ -270,7 +270,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:1446](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1446) +[packages/cozy-client/src/CozyClient.js:1380](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1380) *** @@ -365,7 +365,7 @@ Cozy-Client will automatically call `this.login()` if provided with a token and *Defined in* -[packages/cozy-client/src/CozyClient.js:581](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L581) +[packages/cozy-client/src/CozyClient.js:582](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L582) *** @@ -394,7 +394,7 @@ Contains the fetched token and the client information. These should be stored an *Defined in* -[packages/cozy-client/src/CozyClient.js:1628](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1628) +[packages/cozy-client/src/CozyClient.js:1562](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1562) *** @@ -412,7 +412,7 @@ This mechanism is described in https://github.com/cozy/cozy-client/blob/master/p *Defined in* -[packages/cozy-client/src/CozyClient.js:1609](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1609) +[packages/cozy-client/src/CozyClient.js:1543](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1543) *** @@ -428,13 +428,13 @@ Returns whether the client has been revoked on the server *Defined in* -[packages/cozy-client/src/CozyClient.js:1724](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1724) +[packages/cozy-client/src/CozyClient.js:1658](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1658) *** ### collection -▸ **collection**(`doctype`): `any` +▸ **collection**(`doctype`, `options?`): `any` Forwards to a stack client instance and returns a [DocumentCollection](https://docs.cozy.io/en/cozy-client/api/cozy-stack-client/#DocumentCollection) instance. @@ -444,6 +444,7 @@ a [DocumentCollection](https://docs.cozy.io/en/cozy-client/api/cozy-stack-client | Name | Type | Description | | :------ | :------ | :------ | | `doctype` | `string` | The collection doctype. | +| `options` | `any` | Options to pass to the collection | *Returns* @@ -453,7 +454,7 @@ Collection corresponding to the doctype *Defined in* -[packages/cozy-client/src/CozyClient.js:573](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L573) +[packages/cozy-client/src/CozyClient.js:574](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L574) *** @@ -491,7 +492,7 @@ await client.create('io.cozy.todos', { *Defined in* -[packages/cozy-client/src/CozyClient.js:632](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L632) +[packages/cozy-client/src/CozyClient.js:633](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L633) *** @@ -516,7 +517,7 @@ works with PouchDB *Defined in* -[packages/cozy-client/src/CozyClient.js:652](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L652) +[packages/cozy-client/src/CozyClient.js:653](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L653) *** @@ -537,7 +538,7 @@ If `oauth` options are passed, stackClient is an OAuthStackClient. *Defined in* -[packages/cozy-client/src/CozyClient.js:1762](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1762) +[packages/cozy-client/src/CozyClient.js:1696](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1696) *** @@ -562,7 +563,7 @@ The document that has been deleted *Defined in* -[packages/cozy-client/src/CozyClient.js:914](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L914) +[packages/cozy-client/src/CozyClient.js:915](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L915) *** @@ -587,7 +588,7 @@ The deleted documents *Defined in* -[packages/cozy-client/src/CozyClient.js:928](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L928) +[packages/cozy-client/src/CozyClient.js:929](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L929) *** @@ -607,7 +608,7 @@ The deleted documents *Defined in* -[packages/cozy-client/src/CozyClient.js:1833](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1833) +[packages/cozy-client/src/CozyClient.js:1767](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1767) *** @@ -655,7 +656,7 @@ a method from cozy-client *Defined in* -[packages/cozy-client/src/CozyClient.js:727](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L727) +[packages/cozy-client/src/CozyClient.js:728](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L728) *** @@ -679,7 +680,7 @@ Makes sure that the query exists in the store *Defined in* -[packages/cozy-client/src/CozyClient.js:951](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L951) +[packages/cozy-client/src/CozyClient.js:952](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L952) *** @@ -693,7 +694,7 @@ Makes sure that the query exists in the store *Defined in* -[packages/cozy-client/src/CozyClient.js:1715](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1715) +[packages/cozy-client/src/CozyClient.js:1649](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1649) *** @@ -716,7 +717,7 @@ Makes sure that the query exists in the store *Defined in* -[packages/cozy-client/src/CozyClient.js:577](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L577) +[packages/cozy-client/src/CozyClient.js:578](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L578) *** @@ -745,7 +746,7 @@ Query state *Defined in* -[packages/cozy-client/src/CozyClient.js:1563](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1563) +[packages/cozy-client/src/CozyClient.js:1497](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1497) *** @@ -766,7 +767,7 @@ Query state *Defined in* -[packages/cozy-client/src/CozyClient.js:590](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L590) +[packages/cozy-client/src/CozyClient.js:591](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L591) *** @@ -780,7 +781,7 @@ Query state *Defined in* -[packages/cozy-client/src/CozyClient.js:1421](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1421) +[packages/cozy-client/src/CozyClient.js:1355](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1355) *** @@ -801,7 +802,7 @@ Query state *Defined in* -[packages/cozy-client/src/CozyClient.js:597](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L597) +[packages/cozy-client/src/CozyClient.js:598](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L598) *** @@ -824,7 +825,7 @@ Creates an association that is linked to the store. *Defined in* -[packages/cozy-client/src/CozyClient.js:1428](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1428) +[packages/cozy-client/src/CozyClient.js:1362](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1362) *** @@ -838,7 +839,7 @@ Creates an association that is linked to the store. *Defined in* -[packages/cozy-client/src/CozyClient.js:1815](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1815) +[packages/cozy-client/src/CozyClient.js:1749](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1749) *** @@ -862,7 +863,7 @@ Array of documents or null if the collection does not exist. *Defined in* -[packages/cozy-client/src/CozyClient.js:1464](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1464) +[packages/cozy-client/src/CozyClient.js:1398](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1398) *** @@ -887,7 +888,7 @@ Document or null if the object does not exist. *Defined in* -[packages/cozy-client/src/CozyClient.js:1481](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1481) +[packages/cozy-client/src/CozyClient.js:1415](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1415) *** @@ -922,7 +923,7 @@ One or more mutation to execute *Defined in* -[packages/cozy-client/src/CozyClient.js:826](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L826) +[packages/cozy-client/src/CozyClient.js:827](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L827) *** @@ -942,7 +943,7 @@ One or more mutation to execute *Defined in* -[packages/cozy-client/src/CozyClient.js:1357](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1357) +[packages/cozy-client/src/CozyClient.js:1291](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1291) *** @@ -958,7 +959,7 @@ getInstanceOptions - Returns current instance options, such as domain or app slu *Defined in* -[packages/cozy-client/src/CozyClient.js:1842](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1842) +[packages/cozy-client/src/CozyClient.js:1776](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1776) *** @@ -985,7 +986,7 @@ Get a query from the internal store. *Defined in* -[packages/cozy-client/src/CozyClient.js:1502](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1502) +[packages/cozy-client/src/CozyClient.js:1436](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1436) *** @@ -1014,7 +1015,7 @@ the store up, which in turn will update the ``s and re-render the data. *Defined in* -[packages/cozy-client/src/CozyClient.js:1444](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1444) +[packages/cozy-client/src/CozyClient.js:1378](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1378) *** @@ -1046,7 +1047,7 @@ extract the value corresponding to the given `key` *Defined in* -[packages/cozy-client/src/CozyClient.js:1971](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1971) +[packages/cozy-client/src/CozyClient.js:1905](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1905) *** @@ -1060,7 +1061,7 @@ extract the value corresponding to the given `key` *Defined in* -[packages/cozy-client/src/CozyClient.js:1822](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1822) +[packages/cozy-client/src/CozyClient.js:1756](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1756) *** @@ -1082,7 +1083,7 @@ Sets public attribute and emits event related to revocation *Defined in* -[packages/cozy-client/src/CozyClient.js:1733](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1733) +[packages/cozy-client/src/CozyClient.js:1667](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1667) *** @@ -1104,7 +1105,7 @@ Emits event when token is refreshed *Defined in* -[packages/cozy-client/src/CozyClient.js:1744](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1744) +[packages/cozy-client/src/CozyClient.js:1678](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1678) *** @@ -1130,7 +1131,7 @@ the relationship *Defined in* -[packages/cozy-client/src/CozyClient.js:1397](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1397) +[packages/cozy-client/src/CozyClient.js:1331](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1331) *** @@ -1155,7 +1156,7 @@ Instead, the relationships will have null documents. *Defined in* -[packages/cozy-client/src/CozyClient.js:1377](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1377) +[packages/cozy-client/src/CozyClient.js:1311](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1311) *** @@ -1176,7 +1177,7 @@ Instead, the relationships will have null documents. *Defined in* -[packages/cozy-client/src/CozyClient.js:1412](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1412) +[packages/cozy-client/src/CozyClient.js:1346](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1346) *** @@ -1190,7 +1191,7 @@ Instead, the relationships will have null documents. *Defined in* -[packages/cozy-client/src/CozyClient.js:1585](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1585) +[packages/cozy-client/src/CozyClient.js:1519](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1519) *** @@ -1212,7 +1213,7 @@ loadInstanceOptionsFromDOM - Loads the dataset injected by the Stack in web page *Defined in* -[packages/cozy-client/src/CozyClient.js:1853](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1853) +[packages/cozy-client/src/CozyClient.js:1787](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1787) *** @@ -1230,7 +1231,7 @@ This method is not iso with loadInstanceOptionsFromDOM for now. *Defined in* -[packages/cozy-client/src/CozyClient.js:1874](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1874) +[packages/cozy-client/src/CozyClient.js:1808](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1808) *** @@ -1308,7 +1309,7 @@ Emits *Defined in* -[packages/cozy-client/src/CozyClient.js:1123](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1123) +[packages/cozy-client/src/CozyClient.js:1124](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1124) *** @@ -1335,7 +1336,7 @@ Mutate a document *Defined in* -[packages/cozy-client/src/CozyClient.js:1142](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1142) +[packages/cozy-client/src/CozyClient.js:1143](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1143) *** @@ -1377,7 +1378,7 @@ Dehydrates and adds metadata before saving a document *Defined in* -[packages/cozy-client/src/CozyClient.js:797](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L797) +[packages/cozy-client/src/CozyClient.js:798](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L798) *** @@ -1408,7 +1409,7 @@ please use `fetchQueryAndGetFromState` instead *Defined in* -[packages/cozy-client/src/CozyClient.js:978](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L978) +[packages/cozy-client/src/CozyClient.js:979](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L979) *** @@ -1435,7 +1436,7 @@ All documents matching the query *Defined in* -[packages/cozy-client/src/CozyClient.js:1083](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1083) +[packages/cozy-client/src/CozyClient.js:1084](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1084) *** @@ -1469,7 +1470,7 @@ All documents matching the query *Defined in* -[packages/cozy-client/src/CozyClient.js:1829](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1829) +[packages/cozy-client/src/CozyClient.js:1763](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1763) *** @@ -1494,7 +1495,7 @@ Contains the fetched token and the client information. *Defined in* -[packages/cozy-client/src/CozyClient.js:1579](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1579) +[packages/cozy-client/src/CozyClient.js:1513](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1513) *** @@ -1615,7 +1616,7 @@ Contains the fetched token and the client information. *Defined in* -[packages/cozy-client/src/CozyClient.js:1674](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1674) +[packages/cozy-client/src/CozyClient.js:1608](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1608) *** @@ -1636,7 +1637,7 @@ Contains the fetched token and the client information. *Defined in* -[packages/cozy-client/src/CozyClient.js:1341](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1341) +[packages/cozy-client/src/CozyClient.js:1275](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1275) *** @@ -1662,7 +1663,7 @@ This method will reset the query state to its initial state and refetch it. *Defined in* -[packages/cozy-client/src/CozyClient.js:2000](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L2000) +[packages/cozy-client/src/CozyClient.js:1934](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1934) *** @@ -1685,7 +1686,7 @@ Create or update a document *Defined in* -[packages/cozy-client/src/CozyClient.js:663](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L663) +[packages/cozy-client/src/CozyClient.js:664](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L664) *** @@ -1720,7 +1721,7 @@ save the new resulting settings into database *Defined in* -[packages/cozy-client/src/CozyClient.js:1988](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1988) +[packages/cozy-client/src/CozyClient.js:1922](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1922) *** @@ -1750,7 +1751,7 @@ works with PouchDB *Defined in* -[packages/cozy-client/src/CozyClient.js:696](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L696) +[packages/cozy-client/src/CozyClient.js:697](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L697) *** @@ -1770,7 +1771,7 @@ works with PouchDB *Defined in* -[packages/cozy-client/src/CozyClient.js:1928](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1928) +[packages/cozy-client/src/CozyClient.js:1862](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1862) *** @@ -1794,7 +1795,7 @@ set some data in the store. *Defined in* -[packages/cozy-client/src/CozyClient.js:1901](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1901) +[packages/cozy-client/src/CozyClient.js:1835](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1835) *** @@ -1818,7 +1819,7 @@ we manually call the links onLogin methods *Defined in* -[packages/cozy-client/src/CozyClient.js:1942](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1942) +[packages/cozy-client/src/CozyClient.js:1876](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1876) *** @@ -1842,7 +1843,7 @@ At any time put an error function *Defined in* -[packages/cozy-client/src/CozyClient.js:1914](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1914) +[packages/cozy-client/src/CozyClient.js:1848](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1848) *** @@ -1880,7 +1881,7 @@ use options.force = true. *Defined in* -[packages/cozy-client/src/CozyClient.js:1700](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1700) +[packages/cozy-client/src/CozyClient.js:1634](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1634) *** @@ -1904,7 +1905,7 @@ Contains the fetched token and the client information. These should be stored an *Defined in* -[packages/cozy-client/src/CozyClient.js:1595](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1595) +[packages/cozy-client/src/CozyClient.js:1529](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1529) *** @@ -1918,7 +1919,7 @@ Contains the fetched token and the client information. These should be stored an *Defined in* -[packages/cozy-client/src/CozyClient.js:1921](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1921) +[packages/cozy-client/src/CozyClient.js:1855](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1855) *** @@ -1939,7 +1940,7 @@ Contains the fetched token and the client information. These should be stored an *Defined in* -[packages/cozy-client/src/CozyClient.js:898](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L898) +[packages/cozy-client/src/CozyClient.js:899](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L899) *** @@ -1962,7 +1963,7 @@ Updates multiple documents in one batch. Should have \_id and \_rev *Defined in* -[packages/cozy-client/src/CozyClient.js:679](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L679) +[packages/cozy-client/src/CozyClient.js:680](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L680) *** @@ -1988,7 +1989,7 @@ Created io.cozy.files *Defined in* -[packages/cozy-client/src/CozyClient.js:940](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L940) +[packages/cozy-client/src/CozyClient.js:941](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L941) *** @@ -2008,7 +2009,7 @@ Created io.cozy.files *Defined in* -[packages/cozy-client/src/CozyClient.js:604](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L604) +[packages/cozy-client/src/CozyClient.js:605](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L605) *** @@ -2028,7 +2029,7 @@ Created io.cozy.files *Defined in* -[packages/cozy-client/src/CozyClient.js:1116](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1116) +[packages/cozy-client/src/CozyClient.js:1117](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1117) *** @@ -2164,4 +2165,4 @@ There are at the moment only 2 hooks available. *Defined in* -[packages/cozy-client/src/CozyClient.js:892](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L892) +[packages/cozy-client/src/CozyClient.js:893](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L893) diff --git a/docs/api/cozy-client/classes/QueryDefinition.md b/docs/api/cozy-client/classes/QueryDefinition.md index b8fcc59e68..f7602f0f40 100644 --- a/docs/api/cozy-client/classes/QueryDefinition.md +++ b/docs/api/cozy-client/classes/QueryDefinition.md @@ -28,12 +28,13 @@ from a Cozy. `QueryDefinition`s are sent to links. | `options.partialFilter` | `any` | - | | `options.referenced` | `string` | - | | `options.selector` | `any` | - | +| `options.sharingId` | `string` | - | | `options.skip` | `number` | - | | `options.sort` | `any`\[] | - | *Defined in* -[packages/cozy-client/src/queries/dsl.js:50](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L50) +[packages/cozy-client/src/queries/dsl.js:51](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L51) ## Properties @@ -43,7 +44,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:64](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L64) +[packages/cozy-client/src/queries/dsl.js:65](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L65) *** @@ -53,7 +54,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:63](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L63) +[packages/cozy-client/src/queries/dsl.js:64](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L64) *** @@ -63,7 +64,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:51](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L51) +[packages/cozy-client/src/queries/dsl.js:52](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L52) *** @@ -73,7 +74,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:55](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L55) +[packages/cozy-client/src/queries/dsl.js:56](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L56) *** @@ -83,7 +84,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:52](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L52) +[packages/cozy-client/src/queries/dsl.js:53](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L53) *** @@ -93,7 +94,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:53](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L53) +[packages/cozy-client/src/queries/dsl.js:54](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L54) *** @@ -103,7 +104,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:59](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L59) +[packages/cozy-client/src/queries/dsl.js:60](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L60) *** @@ -113,7 +114,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:56](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L56) +[packages/cozy-client/src/queries/dsl.js:57](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L57) *** @@ -123,7 +124,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:61](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L61) +[packages/cozy-client/src/queries/dsl.js:62](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L62) *** @@ -133,7 +134,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:57](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L57) +[packages/cozy-client/src/queries/dsl.js:58](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L58) *** @@ -143,7 +144,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:60](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L60) +[packages/cozy-client/src/queries/dsl.js:61](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L61) *** @@ -153,7 +154,17 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:54](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L54) +[packages/cozy-client/src/queries/dsl.js:55](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L55) + +*** + +### sharingId + +• **sharingId**: `string` + +*Defined in* + +[packages/cozy-client/src/queries/dsl.js:66](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L66) *** @@ -163,7 +174,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:62](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L62) +[packages/cozy-client/src/queries/dsl.js:63](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L63) *** @@ -173,7 +184,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:58](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L58) +[packages/cozy-client/src/queries/dsl.js:59](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L59) ## Methods @@ -187,7 +198,7 @@ from a Cozy. `QueryDefinition`s are sent to links. *Defined in* -[packages/cozy-client/src/queries/dsl.js:291](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L291) +[packages/cozy-client/src/queries/dsl.js:293](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L293) *** @@ -209,7 +220,7 @@ Check if the selected fields are all included in the selectors *Defined in* -[packages/cozy-client/src/queries/dsl.js:154](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L154) +[packages/cozy-client/src/queries/dsl.js:156](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L156) *** @@ -233,7 +244,7 @@ It is useful to warn the developer when a partial index might be used. *Defined in* -[packages/cozy-client/src/queries/dsl.js:117](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L117) +[packages/cozy-client/src/queries/dsl.js:119](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L119) *** @@ -262,7 +273,7 @@ See https://docs.cozy.io/en/tutorials/data/queries/#sort-data-with-mango *Defined in* -[packages/cozy-client/src/queries/dsl.js:78](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L78) +[packages/cozy-client/src/queries/dsl.js:80](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L80) *** @@ -286,7 +297,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:181](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L181) +[packages/cozy-client/src/queries/dsl.js:183](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L183) *** @@ -310,7 +321,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:194](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L194) +[packages/cozy-client/src/queries/dsl.js:196](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L196) *** @@ -335,7 +346,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:274](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L274) +[packages/cozy-client/src/queries/dsl.js:276](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L276) *** @@ -359,7 +370,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:230](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L230) +[packages/cozy-client/src/queries/dsl.js:232](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L232) *** @@ -383,7 +394,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:287](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L287) +[packages/cozy-client/src/queries/dsl.js:289](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L289) *** @@ -410,7 +421,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:304](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L304) +[packages/cozy-client/src/queries/dsl.js:306](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L306) *** @@ -437,7 +448,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:342](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L342) +[packages/cozy-client/src/queries/dsl.js:344](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L344) *** @@ -466,7 +477,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:324](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L324) +[packages/cozy-client/src/queries/dsl.js:326](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L326) *** @@ -492,7 +503,7 @@ You can find more information about partial indexes [here](https://docs.cozy.io/ *Defined in* -[packages/cozy-client/src/queries/dsl.js:244](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L244) +[packages/cozy-client/src/queries/dsl.js:246](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L246) *** @@ -516,7 +527,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:357](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L357) +[packages/cozy-client/src/queries/dsl.js:359](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L359) *** @@ -540,7 +551,31 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:218](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L218) +[packages/cozy-client/src/queries/dsl.js:220](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L220) + +*** + +### sharingById + +▸ **sharingById**(`id`): [`QueryDefinition`](QueryDefinition.md) + +Use a sharingId to query documents coming from a sharing + +*Parameters* + +| Name | Type | Description | +| :------ | :------ | :------ | +| `id` | `string` | The sharing doc id | + +*Returns* + +[`QueryDefinition`](QueryDefinition.md) + +The QueryDefinition object. + +*Defined in* + +[packages/cozy-client/src/queries/dsl.js:369](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L369) *** @@ -564,7 +599,7 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:255](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L255) +[packages/cozy-client/src/queries/dsl.js:257](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L257) *** @@ -590,12 +625,13 @@ The QueryDefinition object. | `partialFilter` | `any` | | `referenced` | `string` | | `selector` | `any` | +| `sharingId` | `string` | | `skip` | `number` | | `sort` | `any`\[] | *Defined in* -[packages/cozy-client/src/queries/dsl.js:361](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L361) +[packages/cozy-client/src/queries/dsl.js:373](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L373) *** @@ -620,4 +656,4 @@ The QueryDefinition object. *Defined in* -[packages/cozy-client/src/queries/dsl.js:205](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L205) +[packages/cozy-client/src/queries/dsl.js:207](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/queries/dsl.js#L207) diff --git a/docs/api/cozy-client/classes/StackLink.md b/docs/api/cozy-client/classes/StackLink.md index 4f31a51826..45ef8cb611 100644 --- a/docs/api/cozy-client/classes/StackLink.md +++ b/docs/api/cozy-client/classes/StackLink.md @@ -81,7 +81,7 @@ Transfers queries and mutations to a remote stack *Defined in* -[packages/cozy-client/src/links/StackLink.js:142](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/links/StackLink.js#L142) +[packages/cozy-client/src/links/StackLink.js:154](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/links/StackLink.js#L154) *** diff --git a/docs/api/cozy-pouch-link/classes/PouchLink.md b/docs/api/cozy-pouch-link/classes/PouchLink.md index 4cfafe653b..ca9a77f479 100644 --- a/docs/api/cozy-pouch-link/classes/PouchLink.md +++ b/docs/api/cozy-pouch-link/classes/PouchLink.md @@ -172,7 +172,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:741](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L741) +[CozyPouchLink.js:744](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L744) *** @@ -192,7 +192,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:727](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L727) +[CozyPouchLink.js:730](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L730) *** @@ -212,7 +212,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:690](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L690) +[CozyPouchLink.js:693](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L693) *** @@ -232,7 +232,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:695](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L695) +[CozyPouchLink.js:698](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L698) *** @@ -253,7 +253,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:745](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L745) +[CozyPouchLink.js:748](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L748) *** @@ -273,7 +273,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:708](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L708) +[CozyPouchLink.js:711](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L711) *** @@ -293,7 +293,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:719](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L719) +[CozyPouchLink.js:722](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L722) *** @@ -316,7 +316,7 @@ CozyLink.constructor *Defined in* -[CozyPouchLink.js:646](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L646) +[CozyPouchLink.js:649](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L649) *** @@ -842,7 +842,7 @@ Emits pouchlink:sync:stop event *Defined in* -[CozyPouchLink.js:775](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L775) +[CozyPouchLink.js:778](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L778) *** @@ -862,7 +862,7 @@ Emits pouchlink:sync:stop event *Defined in* -[CozyPouchLink.js:699](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L699) +[CozyPouchLink.js:702](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L702) *** @@ -882,7 +882,7 @@ Emits pouchlink:sync:stop event *Defined in* -[CozyPouchLink.js:704](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L704) +[CozyPouchLink.js:707](https://github.com/cozy/cozy-client/blob/master/packages/cozy-pouch-link/src/CozyPouchLink.js#L707) *** diff --git a/docs/api/cozy-stack-client.md b/docs/api/cozy-stack-client.md index 10e8f52343..0a8a16cb84 100644 --- a/docs/api/cozy-stack-client.md +++ b/docs/api/cozy-stack-client.md @@ -139,6 +139,10 @@ See getAccessToken()string

Get the app token string

+
sharedDriveApiPrefix(driveId)string
+

Returns a FileCollection API prefix for manipulating a shared +drive's files.

+
getIconURL()

Get Icon URL using blob mechanism if OAuth connected or using preloaded url when blob not needed

@@ -200,6 +204,8 @@ Deleted and design docs are filtered by default, thus documents are retrieved in (include_docs is set to true in the parameters of _changes).

You should use fetchChangesRaw to have low level control on _changes parameters.

+
CozyStackClient : module:"./CozyStackClient.js"
+
IOCozyFolder : object

Folder

@@ -224,6 +230,9 @@ Deleted and design docs are filtered by default, thus documents are retrieved in
OAuthClient : object

Document representing a io.cozy.oauth.clients

+
FileCollectionOptions : object
+

Options that can be passed to FileCollection's constructor

+
ArchivePages : object

Attributes used for create archive link by ids

@@ -365,7 +374,7 @@ Main API against the `cozy-stack` server. **Kind**: global class * [CozyStackClient](#CozyStackClient) - * [.collection(doctype)](#CozyStackClient+collection) ⇒ [DocumentCollection](#DocumentCollection) + * [.collection(doctype, options)](#CozyStackClient+collection) ⇒ [DocumentCollection](#DocumentCollection) * [.fetch(method, path, [body], [opts])](#CozyStackClient+fetch) ⇒ object * [.refreshToken()](#CozyStackClient+refreshToken) ⇒ Promise * [.fetchJSON(method, path, body, options)](#CozyStackClient+fetchJSON) ⇒ object @@ -374,7 +383,7 @@ Main API against the `cozy-stack` server. -### cozyStackClient.collection(doctype) ⇒ [DocumentCollection](#DocumentCollection) +### cozyStackClient.collection(doctype, options) ⇒ [DocumentCollection](#DocumentCollection) Creates a [DocumentCollection](#DocumentCollection) instance. **Kind**: instance method of [CozyStackClient](#CozyStackClient) @@ -382,6 +391,7 @@ Creates a [DocumentCollection](#DocumentCollection) instance. | Param | Type | Description | | --- | --- | --- | | doctype | string | The collection doctype. | +| options | object | Options to pass to the collection. | @@ -752,6 +762,7 @@ files associated to a specific document **Kind**: global class * [FileCollection](#FileCollection) + * [new FileCollection(doctype, stackClient, [options])](#new_FileCollection_new) * [.forceFileDownload](#FileCollection+forceFileDownload) * [.get(id)](#FileCollection+get) ⇒ Object * [.getAll(ids)](#FileCollection+getAll) ⇒ Promise.<{data, meta, execution\_stats}> @@ -787,6 +798,16 @@ files associated to a specific document * [.removeNotSynchronizedDirectories(oauthClient, directories)](#FileCollection+removeNotSynchronizedDirectories) * [.getOrCreateSharedDrivesDirectory()](#FileCollection+getOrCreateSharedDrivesDirectory) ⇒ [IOCozyFolder](#IOCozyFolder) + + +### new FileCollection(doctype, stackClient, [options]) + +| Param | Type | Description | +| --- | --- | --- | +| doctype | string | Doctype of the collection (should be `io.cozy.files`) | +| stackClient | [CozyStackClient](#CozyStackClient) | The client used to make requests to the serve | +| [options] | [FileCollectionOptions](#FileCollectionOptions) | The collection options | + ### fileCollection.forceFileDownload @@ -2425,6 +2446,19 @@ Get the app token string **Kind**: global function **Returns**: string - token **See**: CozyStackClient.getAccessToken + + +## sharedDriveApiPrefix(driveId) ⇒ string +Returns a FileCollection API prefix for manipulating a shared +drive's files. + +**Kind**: global function +**Returns**: string - The API prefix to manipulate the drive's files + +| Param | Type | Description | +| --- | --- | --- | +| driveId | string | The shared drive ID | + ## getIconURL() @@ -2615,6 +2649,97 @@ You should use fetchChangesRaw to have low level control on _changes parameters. | newLastSeq | string | | documents | Array.<object> | + + +## CozyStackClient : module:"./CozyStackClient.js" +**Kind**: global typedef + +* [CozyStackClient](#CozyStackClient) : module:"./CozyStackClient.js" + * [.collection(doctype, options)](#CozyStackClient+collection) ⇒ [DocumentCollection](#DocumentCollection) + * [.fetch(method, path, [body], [opts])](#CozyStackClient+fetch) ⇒ object + * [.refreshToken()](#CozyStackClient+refreshToken) ⇒ Promise + * [.fetchJSON(method, path, body, options)](#CozyStackClient+fetchJSON) ⇒ object + * [.setToken(token)](#CozyStackClient+setToken) + * [.getAccessToken()](#CozyStackClient+getAccessToken) ⇒ string + + + +### cozyStackClient.collection(doctype, options) ⇒ [DocumentCollection](#DocumentCollection) +Creates a [DocumentCollection](#DocumentCollection) instance. + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) + +| Param | Type | Description | +| --- | --- | --- | +| doctype | string | The collection doctype. | +| options | object | Options to pass to the collection. | + + + +### cozyStackClient.fetch(method, path, [body], [opts]) ⇒ object +Fetches an endpoint in an authorized way. + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) +**Throws**: + +- FetchError + + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| method | string | | The HTTP method. | +| path | string | | The URI. | +| [body] | object | | The payload. | +| [opts] | object | {} | Options for fetch | + + + +### cozyStackClient.refreshToken() ⇒ Promise +Retrieves a new app token by refreshing the currently used token. + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) +**Returns**: Promise - A promise that resolves with a new AccessToken object +**Throws**: + +- Error The client should already have an access token to use this function +- Error The client couldn't fetch a new token + + + +### cozyStackClient.fetchJSON(method, path, body, options) ⇒ object +Fetches JSON in an authorized way. + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) +**Throws**: + +- FetchError + + +| Param | Type | Description | +| --- | --- | --- | +| method | string | The HTTP method. | +| path | string | The URI. | +| body | object | The payload. | +| options | object | Options | + + + +### cozyStackClient.setToken(token) +Change or set the API token + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) + +| Param | Type | Description | +| --- | --- | --- | +| token | string \| AppToken \| AccessToken | Stack API token | + + + +### cozyStackClient.getAccessToken() ⇒ string +Get the access token string, being an oauth token or an app token + +**Kind**: instance method of [CozyStackClient](#CozyStackClient) +**Returns**: string - token ## IOCozyFolder : object @@ -2968,6 +3093,18 @@ If this is the case, call the onRevocationChange callback **Kind**: instance method of [OAuthClient](#OAuthClient) **Returns**: Promise.<boolean> - A Promise that resolves to `false` if client is still valid, or `true` if it has been revoked. + + +## FileCollectionOptions : object +Options that can be passed to FileCollection's constructor + +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| [driveId] | string | ID of the shared drive targeted by the collection | + ## ArchivePages : object @@ -3221,7 +3358,7 @@ Define a recipient that can be used as target of a sharing * [CozyStackClient](#CozyStackClient) : object - * [.collection(doctype)](#CozyStackClient+collection) ⇒ [DocumentCollection](#DocumentCollection) + * [.collection(doctype, options)](#CozyStackClient+collection) ⇒ [DocumentCollection](#DocumentCollection) * [.fetch(method, path, [body], [opts])](#CozyStackClient+fetch) ⇒ object * [.refreshToken()](#CozyStackClient+refreshToken) ⇒ Promise * [.fetchJSON(method, path, body, options)](#CozyStackClient+fetchJSON) ⇒ object @@ -3230,7 +3367,7 @@ Define a recipient that can be used as target of a sharing -### cozyStackClient.collection(doctype) ⇒ [DocumentCollection](#DocumentCollection) +### cozyStackClient.collection(doctype, options) ⇒ [DocumentCollection](#DocumentCollection) Creates a [DocumentCollection](#DocumentCollection) instance. **Kind**: instance method of [CozyStackClient](#CozyStackClient) @@ -3238,6 +3375,7 @@ Creates a [DocumentCollection](#DocumentCollection) instance. | Param | Type | Description | | --- | --- | --- | | doctype | string | The collection doctype. | +| options | object | Options to pass to the collection. | diff --git a/packages/cozy-client/src/CozyClient.js b/packages/cozy-client/src/CozyClient.js index efd1404a7e..378ad5e6bb 100644 --- a/packages/cozy-client/src/CozyClient.js +++ b/packages/cozy-client/src/CozyClient.js @@ -568,10 +568,11 @@ class CozyClient { * a [DocumentCollection]{@link https://docs.cozy.io/en/cozy-client/api/cozy-stack-client/#DocumentCollection} instance. * * @param {string} doctype The collection doctype. + * @param {object} options Options to pass to the collection * @returns {import("./types").DocumentCollection} Collection corresponding to the doctype */ - collection(doctype) { - return this.getStackClient().collection(doctype) + collection(doctype, options = {}) { + return this.getStackClient().collection(doctype, options) } fetch(method, path, body, options = {}) { @@ -1191,73 +1192,6 @@ client.query(Q('io.cozy.bills'))`) return mainResponse } - /** - * Save the document or array of documents into the persisted storage (if any) - * - * @private - * @param {CozyClientDocument | Array} data - Document or array of documents to be saved - * @returns {Promise} - */ - async persistVirtualDocuments(definition, data) { - const enforceList = ['io.cozy.files.shortcuts'] - - const enforce = enforceList.includes(definition.doctype) - - if (definition.doctype === 'io.cozy.apps_registry') { - // io.cozy.apps_registry has a dedicated `maintenance` endpoint on cozy-stack that - // returns data different than the one stored in database - // As we want to have transparent queries, whether it uses the stack API or Pouch, - // we store the full response into a single doc, with a `maintenance` _id - // and a special `cozyPouchData` attribute, to highlight this special case - return await this.persistVirtualDocument( - { - _type: 'io.cozy.apps_registry', - _id: definition.id, - // @ts-ignore - cozyPouchData: data - }, - enforce - ) - } - - if (!Array.isArray(data)) { - await this.persistVirtualDocument(data, enforce) - } else { - const documentsToPersist = data.filter(document => { - if (!document || document.cozyLocalOnly) { - return false - } - - if ((!document.meta?.rev && !document._rev) || enforce) { - return true - } - - return false - }) - for (const document of documentsToPersist) { - await this.persistVirtualDocument(document, enforce) - } - } - } - - /** - * Save the document or array of documents into the persisted storage (if any) - * - * @private - * @param {CozyClientDocument} document - Document to be saved - * @param {boolean} enforce - When true, save the document even if `meta.rev` or `_rev` exist - * @returns {Promise} - */ - async persistVirtualDocument(document, enforce) { - if (!document || document.cozyLocalOnly) { - return - } - - if ((!document.meta?.rev && !document._rev) || enforce) { - await this.chain.persistCozyData(document) - } - } - /** * Fetch relationships for a response (can be several docs). * Fills the `relationships` attribute of each documents. diff --git a/packages/cozy-client/src/links/StackLink.js b/packages/cozy-client/src/links/StackLink.js index fdb50e670c..42a9d7bfda 100644 --- a/packages/cozy-client/src/links/StackLink.js +++ b/packages/cozy-client/src/links/StackLink.js @@ -117,12 +117,24 @@ export default class StackLink extends CozyLink { * @returns {Promise} */ executeQuery(query) { - const { doctype, selector, id, ids, referenced, ...options } = query + const { + doctype, + selector, + id, + ids, + referenced, + sharingId, + ...rawOptions + } = query + let options = { ...rawOptions, driveId: undefined } if (!doctype) { logger.warn('Bad query', query) throw new Error('No doctype found in a query definition') } - const collection = this.stackClient.collection(doctype) + if (doctype === DOCTYPE_FILES && sharingId) { + options = { ...options, driveId: sharingId } + } + const collection = this.stackClient.collection(doctype, options) if (id) { return collection.get(id, query) } diff --git a/packages/cozy-client/src/links/StackLink.spec.js b/packages/cozy-client/src/links/StackLink.spec.js index 891d902686..6e5d0bcbc3 100644 --- a/packages/cozy-client/src/links/StackLink.spec.js +++ b/packages/cozy-client/src/links/StackLink.spec.js @@ -18,7 +18,10 @@ describe('StackLink', () => { stackClient.collection().all.mockReset() await link.request(query) expect(stackClient.collection().all).toHaveBeenCalled() - expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos') + expect(stackClient.collection).toHaveBeenCalledWith( + 'io.cozy.todos', + expect.anything() + ) }) it('should execute queries with a selector', async () => { @@ -36,7 +39,10 @@ describe('StackLink', () => { stackClient.collection().find.mockReset() await link.request(query) expect(stackClient.collection().find).toHaveBeenCalled() - expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos') + expect(stackClient.collection).toHaveBeenCalledWith( + 'io.cozy.todos', + expect.anything() + ) }) it('should use all if a no sort option is given', async () => { @@ -44,7 +50,10 @@ describe('StackLink', () => { stackClient.collection().all.mockReset() await link.request(query) expect(stackClient.collection().all).toHaveBeenCalled() - expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos') + expect(stackClient.collection).toHaveBeenCalledWith( + 'io.cozy.todos', + expect.anything() + ) }) it('should use find if a partialFilter is given', async () => { @@ -52,7 +61,10 @@ describe('StackLink', () => { stackClient.collection().find.mockReset() await link.request(query) expect(stackClient.collection().find).toHaveBeenCalled() - expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos') + expect(stackClient.collection).toHaveBeenCalledWith( + 'io.cozy.todos', + expect.anything() + ) }) it('should use find if fields are given', async () => { @@ -60,7 +72,10 @@ describe('StackLink', () => { stackClient.collection().find.mockReset() await link.request(query) expect(stackClient.collection().find).toHaveBeenCalled() - expect(stackClient.collection).toHaveBeenCalledWith('io.cozy.todos') + expect(stackClient.collection).toHaveBeenCalledWith( + 'io.cozy.todos', + expect.anything() + ) }) }) diff --git a/packages/cozy-client/src/models/file.spec.js b/packages/cozy-client/src/models/file.spec.js index f96e72bc89..fddc4e0546 100644 --- a/packages/cozy-client/src/models/file.spec.js +++ b/packages/cozy-client/src/models/file.spec.js @@ -430,7 +430,8 @@ describe('File Model', () => { 'mydoc.odt' ) expect(cozyClient.stackClient.collection).toHaveBeenCalledWith( - 'io.cozy.files' + 'io.cozy.files', + expect.anything() ) expect(getSpy).toHaveBeenCalledWith( 'parent', @@ -447,7 +448,8 @@ describe('File Model', () => { 'mydoc.odt' ) expect(cozyClient.stackClient.collection).toHaveBeenCalledWith( - 'io.cozy.files' + 'io.cozy.files', + expect.anything() ) expect(getSpy).toHaveBeenCalledWith( 'parent', diff --git a/packages/cozy-client/src/queries/dsl.js b/packages/cozy-client/src/queries/dsl.js index 9a9ba4ffc5..5b6b00130c 100644 --- a/packages/cozy-client/src/queries/dsl.js +++ b/packages/cozy-client/src/queries/dsl.js @@ -46,6 +46,7 @@ class QueryDefinition { * @param {number|null} [options.skip] - The number of docs to skip. * @param {import('../types').CouchDBViewCursor} [options.cursor] - The cursor to paginate views. * @param {string} [options.bookmark] - The bookmark to paginate mango queries. + * @param {string} [options.sharingId] - The id of the sharing */ constructor(options = {}) { this.doctype = options.doctype @@ -62,6 +63,7 @@ class QueryDefinition { this.skip = options.skip this.cursor = options.cursor this.bookmark = options.bookmark + this.sharingId = options.sharingId } /** @@ -358,6 +360,16 @@ class QueryDefinition { return new QueryDefinition({ ...this.toDefinition(), referenced: document }) } + /** + * Use a sharingId to query documents coming from a sharing + * + * @param {string} id - The sharing doc id + * @returns {QueryDefinition} The QueryDefinition object. + */ + sharingById(id) { + return new QueryDefinition({ ...this.toDefinition(), sharingId: id }) + } + toDefinition() { return { doctype: this.doctype, @@ -373,7 +385,8 @@ class QueryDefinition { limit: this.limit, skip: this.skip, cursor: this.cursor, - bookmark: this.bookmark + bookmark: this.bookmark, + sharingId: this.sharingId } } } diff --git a/packages/cozy-client/src/storage.js b/packages/cozy-client/src/storage.js index 163ec2abc0..62db3bc78a 100644 --- a/packages/cozy-client/src/storage.js +++ b/packages/cozy-client/src/storage.js @@ -24,6 +24,10 @@ export const shouldDocumentBePersisted = (document, shouldEnforce = false) => { if ((!document.meta?.rev && !document._rev) || shouldEnforce) { return true } + if (document.driveId && document._type === 'io.cozy.files') { + // Special case for files in shared drives, so remote files could be locally persisted + return true + } return false } diff --git a/packages/cozy-client/src/store/__snapshots__/queries.spec.js.snap b/packages/cozy-client/src/store/__snapshots__/queries.spec.js.snap index f428d40b12..b20ee44821 100644 --- a/packages/cozy-client/src/store/__snapshots__/queries.spec.js.snap +++ b/packages/cozy-client/src/store/__snapshots__/queries.spec.js.snap @@ -19,6 +19,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -60,6 +61,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -100,6 +102,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -140,6 +143,7 @@ Object { }, "done": true, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -180,6 +184,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -217,6 +222,7 @@ Object { "selector": Object { "done": true, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -259,6 +265,7 @@ Object { "selector": Object { "done": false, }, + "sharingId": undefined, "skip": undefined, "sort": Array [ Object { @@ -298,6 +305,7 @@ Object { "selector": Object { "done": true, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -339,6 +347,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -375,6 +384,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -415,6 +425,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -450,6 +461,7 @@ Object { "selector": Object { "done": true, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -492,6 +504,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -525,6 +538,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -565,6 +579,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -602,6 +617,7 @@ Object { "selector": Object { "done": true, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -646,6 +662,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -681,6 +698,7 @@ Object { "selector": Object { "done": false, }, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -723,6 +741,7 @@ Object { "partialFilter": undefined, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, @@ -761,6 +780,7 @@ Object { }, "referenced": undefined, "selector": undefined, + "sharingId": undefined, "skip": undefined, "sort": undefined, }, diff --git a/packages/cozy-client/src/types.js b/packages/cozy-client/src/types.js index 994b4dd710..4343d525de 100644 --- a/packages/cozy-client/src/types.js +++ b/packages/cozy-client/src/types.js @@ -457,6 +457,7 @@ import { QueryDefinition } from './queries/dsl' * @property {CozyMetadata} [cozyMetadata] - Cozy Metadata * @property {CozyClientDocumentMeta} [meta] - Pouch Metadata * @property {boolean} [cozyLocalOnly] - When true the document should NOT be replicated to the remote database + * @property {string} [driveId] - Id of a shared drive, only for shared io.cozy.files */ /** diff --git a/packages/cozy-client/types/CozyClient.d.ts b/packages/cozy-client/types/CozyClient.d.ts index 994201eacc..83f0a39986 100644 --- a/packages/cozy-client/types/CozyClient.d.ts +++ b/packages/cozy-client/types/CozyClient.d.ts @@ -40,6 +40,10 @@ export type CozyClientDocument = { * - When true the document should NOT be replicated to the remote database */ cozyLocalOnly?: boolean; + /** + * - Id of a shared drive, only for shared io.cozy.files + */ + driveId?: string; }; export type ClientOptions = { client?: object; @@ -361,9 +365,10 @@ declare class CozyClient { * a [DocumentCollection]{@link https://docs.cozy.io/en/cozy-client/api/cozy-stack-client/#DocumentCollection} instance. * * @param {string} doctype The collection doctype. + * @param {object} options Options to pass to the collection * @returns {import("./types").DocumentCollection} Collection corresponding to the doctype */ - collection(doctype: string): import("./types").DocumentCollection; + collection(doctype: string, options?: object): import("./types").DocumentCollection; fetch(method: any, path: any, body: any, options?: {}): any; all(doctype: any): QueryDefinition; find(doctype: any, selector?: any): QueryDefinition; @@ -559,23 +564,6 @@ declare class CozyClient { * @returns {Promise} */ private requestQuery; - /** - * Save the document or array of documents into the persisted storage (if any) - * - * @private - * @param {CozyClientDocument | Array} data - Document or array of documents to be saved - * @returns {Promise} - */ - private persistVirtualDocuments; - /** - * Save the document or array of documents into the persisted storage (if any) - * - * @private - * @param {CozyClientDocument} document - Document to be saved - * @param {boolean} enforce - When true, save the document even if `meta.rev` or `_rev` exist - * @returns {Promise} - */ - private persistVirtualDocument; /** * Fetch relationships for a response (can be several docs). * Fills the `relationships` attribute of each documents. diff --git a/packages/cozy-client/types/queries/dsl.d.ts b/packages/cozy-client/types/queries/dsl.d.ts index df2fd23a5a..8bf6f32b78 100644 --- a/packages/cozy-client/types/queries/dsl.d.ts +++ b/packages/cozy-client/types/queries/dsl.d.ts @@ -125,6 +125,7 @@ export class QueryDefinition { * @param {number|null} [options.skip] - The number of docs to skip. * @param {import('../types').CouchDBViewCursor} [options.cursor] - The cursor to paginate views. * @param {string} [options.bookmark] - The bookmark to paginate mango queries. + * @param {string} [options.sharingId] - The id of the sharing */ constructor(options?: { doctype: import('../types').Doctype; @@ -141,6 +142,7 @@ export class QueryDefinition { skip: number | null; cursor: import('../types').CouchDBViewCursor; bookmark: string; + sharingId: string; }); doctype: string; id: string; @@ -156,6 +158,7 @@ export class QueryDefinition { skip: number; cursor: import("../types").CouchDBViewCursor; bookmark: string; + sharingId: string; /** * Checks if the sort order matches the index' fields order. * @@ -291,6 +294,13 @@ export class QueryDefinition { * @returns {QueryDefinition} The QueryDefinition object. */ referencedBy(document: object): QueryDefinition; + /** + * Use a sharingId to query documents coming from a sharing + * + * @param {string} id - The sharing doc id + * @returns {QueryDefinition} The QueryDefinition object. + */ + sharingById(id: string): QueryDefinition; toDefinition(): { doctype: string; id: string; @@ -306,6 +316,7 @@ export class QueryDefinition { skip: number; cursor: import("../types").CouchDBViewCursor; bookmark: string; + sharingId: string; }; } declare const CREATE_DOCUMENT: "CREATE_DOCUMENT"; diff --git a/packages/cozy-client/types/storage.d.ts b/packages/cozy-client/types/storage.d.ts index 7398fc4ab9..d57d6c816c 100644 --- a/packages/cozy-client/types/storage.d.ts +++ b/packages/cozy-client/types/storage.d.ts @@ -43,6 +43,10 @@ export type CozyClientDocument = { * - When true the document should NOT be replicated to the remote database */ cozyLocalOnly?: boolean; + /** + * - Id of a shared drive, only for shared io.cozy.files + */ + driveId?: string; }; import CozyClient from "./CozyClient"; import { QueryDefinition } from "./queries/dsl"; diff --git a/packages/cozy-client/types/types.d.ts b/packages/cozy-client/types/types.d.ts index 16b203d9fd..833d02cdfb 100644 --- a/packages/cozy-client/types/types.d.ts +++ b/packages/cozy-client/types/types.d.ts @@ -815,6 +815,10 @@ export type CozyClientDocument = { * - When true the document should NOT be replicated to the remote database */ cozyLocalOnly?: boolean; + /** + * - Id of a shared drive, only for shared io.cozy.files + */ + driveId?: string; }; /** * - A io.cozy.files document's metadata diff --git a/packages/cozy-pouch-link/src/CozyPouchLink.js b/packages/cozy-pouch-link/src/CozyPouchLink.js index abb78d489b..a736015983 100644 --- a/packages/cozy-pouch-link/src/CozyPouchLink.js +++ b/packages/cozy-pouch-link/src/CozyPouchLink.js @@ -604,7 +604,8 @@ class PouchLink extends CozyLink { ids, skip, indexedFields, - partialFilter + partialFilter, + sharingId }) { const engine = this.getQueryEngineFromDoctype(doctype) @@ -620,7 +621,9 @@ class PouchLink extends CozyLink { selector, sort, indexedFields, - partialFilter + partialFilter, + doctype, + sharingId }) const findOpts = { diff --git a/packages/cozy-pouch-link/src/helpers.js b/packages/cozy-pouch-link/src/helpers.js index e3e73ae585..9ac623dc1b 100644 --- a/packages/cozy-pouch-link/src/helpers.js +++ b/packages/cozy-pouch-link/src/helpers.js @@ -25,7 +25,9 @@ helpers.normalizeFindSelector = ({ selector, sort, indexedFields, - partialFilter + partialFilter, + doctype, + sharingId }) => { let findSelector = selector || {} if (indexedFields) { @@ -57,6 +59,12 @@ helpers.normalizeFindSelector = ({ } } + if (sharingId && doctype === 'io.cozy.files') { + // The sharingId is currently only used for io.cozy.files and saved as 'driveId' + // by the stack response + findSelector['driveId'] = sharingId + } + const mergedSelector = partialFilter ? merge({ ...findSelector }, partialFilter) : findSelector diff --git a/packages/cozy-pouch-link/src/helpers.spec.js b/packages/cozy-pouch-link/src/helpers.spec.js index be855e712c..c3072c5db4 100644 --- a/packages/cozy-pouch-link/src/helpers.spec.js +++ b/packages/cozy-pouch-link/src/helpers.spec.js @@ -99,5 +99,19 @@ describe('Helpers', () => { SOME_INDEXED_FIELD: { $gt: null } }) }) + + it('should add driveId to selector when sharingId is provided for io.cozy.files', () => { + const selector = { dir_id: '123' } + + const findSelector = normalizeFindSelector({ + doctype: 'io.cozy.files', + selector, + sharingId: 'sharingId' + }) + expect(findSelector).toStrictEqual({ + dir_id: '123', + driveId: 'sharingId' + }) + }) }) }) diff --git a/packages/cozy-pouch-link/types/CozyPouchLink.d.ts b/packages/cozy-pouch-link/types/CozyPouchLink.d.ts index 6141d05701..552140f5ff 100644 --- a/packages/cozy-pouch-link/types/CozyPouchLink.d.ts +++ b/packages/cozy-pouch-link/types/CozyPouchLink.d.ts @@ -215,7 +215,7 @@ declare class PouchLink extends CozyLink { */ needsToWaitWarmup(doctype: string): Promise; hasIndex(name: any): boolean; - executeQuery({ doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter }: { + executeQuery({ doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter, sharingId }: { doctype: any; selector: any; sort: any; @@ -226,6 +226,7 @@ declare class PouchLink extends CozyLink { skip: any; indexedFields: any; partialFilter: any; + sharingId: any; }): Promise; executeMutation(mutation: any, options: any, result: any, forward: any): Promise; createDocument(mutation: any): Promise; diff --git a/packages/cozy-pouch-link/types/helpers.d.ts b/packages/cozy-pouch-link/types/helpers.d.ts index 7aa760d62a..f6830ed2c9 100644 --- a/packages/cozy-pouch-link/types/helpers.d.ts +++ b/packages/cozy-pouch-link/types/helpers.d.ts @@ -5,10 +5,12 @@ declare namespace helpers { function isDesignDocument(doc: any): boolean; function isDeletedDocument(doc: any): any; function insertBulkDocs(db: any, docs: any): Promise; - function normalizeFindSelector({ selector, sort, indexedFields, partialFilter }: { + function normalizeFindSelector({ selector, sort, indexedFields, partialFilter, doctype, sharingId }: { selector: any; sort: any; indexedFields: any; partialFilter: any; + doctype: any; + sharingId: any; }): any; } diff --git a/packages/cozy-stack-client/src/CozyStackClient.js b/packages/cozy-stack-client/src/CozyStackClient.js index b37b277219..749a4fec9d 100644 --- a/packages/cozy-stack-client/src/CozyStackClient.js +++ b/packages/cozy-stack-client/src/CozyStackClient.js @@ -77,44 +77,45 @@ class CozyStackClient { * Creates a {@link DocumentCollection} instance. * * @param {string} doctype The collection doctype. + * @param {object} options Options to pass to the collection. * @returns {DocumentCollection} */ - collection(doctype) { + collection(doctype, options = {}) { if (!doctype) { throw new Error('CozyStackClient.collection() called without a doctype') } switch (doctype) { case APPS_DOCTYPE: - return new AppCollection(this) + return new AppCollection(this, options) case KONNECTORS_DOCTYPE: - return new KonnectorCollection(this) + return new KonnectorCollection(this, options) case 'io.cozy.files': - return new FileCollection(doctype, this) + return new FileCollection(doctype, this, options) case 'io.cozy.sharings': - return new SharingCollection(doctype, this) + return new SharingCollection(doctype, this, options) case 'io.cozy.permissions': - return new PermissionCollection(doctype, this) + return new PermissionCollection(doctype, this, options) case CONTACTS_DOCTYPE: - return new ContactsCollection(doctype, this) + return new ContactsCollection(doctype, this, options) case TRIGGERS_DOCTYPE: - return new TriggerCollection(this) + return new TriggerCollection(this, options) case JOBS_DOCTYPE: - return new JobCollection(this) + return new JobCollection(this, options) case SETTINGS_DOCTYPE: - return new SettingsCollection(this) + return new SettingsCollection(this, options) case NOTES_DOCTYPE: - return new NotesCollection(this) + return new NotesCollection(this, options) case OAUTH_CLIENTS_DOCTYPE: - return new OAuthClientsCollection(this) + return new OAuthClientsCollection(this, options) case SHORTCUTS_DOCTYPE: - return new ShortcutsCollection(this) + return new ShortcutsCollection(this, options) case APPS_REGISTRY_DOCTYPE: - return new AppsRegistryCollection(this) + return new AppsRegistryCollection(this, options) case NEXTCLOUD_FILES_DOCTYPE: - return new NextcloudFilesCollection(this) + return new NextcloudFilesCollection(this, options) default: - return new DocumentCollection(doctype, this) + return new DocumentCollection(doctype, this, options) } } diff --git a/packages/cozy-stack-client/src/FileCollection.js b/packages/cozy-stack-client/src/FileCollection.js index 3fb4a3904d..71f5b59d1e 100644 --- a/packages/cozy-stack-client/src/FileCollection.js +++ b/packages/cozy-stack-client/src/FileCollection.js @@ -13,14 +13,21 @@ import { dontThrowNotFoundError } from './Collection' import { getIllegalCharacters } from './getIllegalCharacter' import * as querystring from './querystring' import logger from './logger' + +/** + * @typedef {module:"./CozyStackClient.js"} CozyStackClient + */ + /** * @typedef {object} IOCozyFolder Folder */ + /** * @typedef {object} SpecificFileAttributesForKonnector Specific file attributes for creation for konnector * @property {string} sourceAccount the id of the source account used by a konnector * @property {string} sourceAccountIdentifier the unique identifier of the account targeted by the connector */ + /** * Cursor used for Mango queries pagination * @@ -79,6 +86,13 @@ import logger from './logger' * @property {string} _type - Doctype of the client (i.e. io.cozy.oauth.clients) */ +/** + * Options that can be passed to FileCollection's constructor + * + * @typedef {object} FileCollectionOptions + * @property {string} [driveId] - ID of the shared drive targeted by the collection + */ + const ROOT_DIR_ID = 'io.cozy.files.root-dir' const CONTENT_TYPE_OCTET_STREAM = 'application/octet-stream' @@ -185,6 +199,16 @@ const dirName = path => { return path.substring(0, lastIndex) } +/** + * Returns a FileCollection API prefix for manipulating a shared + * drive's files. + * + * @param {string} driveId - The shared drive ID + * + * @returns {string} The API prefix to manipulate the drive's files + */ +const sharedDriveApiPrefix = driveId => uri`/sharings/drives/${driveId}` + /** * Implements `DocumentCollection` API along with specific methods for * `io.cozy.files`. @@ -194,9 +218,17 @@ const dirName = path => { * files associated to a specific document */ class FileCollection extends DocumentCollection { - constructor(doctype, stackClient) { - super(doctype, stackClient) + /** + * @param {string} doctype - Doctype of the collection (should be `io.cozy.files`) + * @param {CozyStackClient} stackClient -The client used to make requests to the serve + * @param {FileCollectionOptions} [options] - The collection options + */ + constructor(doctype, stackClient, options = {}) { + super(doctype, stackClient, options) this.specialDirectories = {} + this.prefix = options.driveId + ? sharedDriveApiPrefix(options.driveId) + : '/files' } /** @@ -220,7 +252,7 @@ class FileCollection extends DocumentCollection { try { resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/_all_docs?include_docs=true`, + this.prefix + uri`/_all_docs?include_docs=true`, { keys: ids } @@ -240,7 +272,7 @@ class FileCollection extends DocumentCollection { async fetchFindFiles(selector, options) { return this.stackClient.fetchJSON( 'POST', - '/files/_find', + this.prefix + `/_find`, this.toMangoOptions(selector, options) ) } @@ -259,7 +291,7 @@ class FileCollection extends DocumentCollection { const { skip = 0 } = options let resp try { - const path = '/files/_find' + const path = this.prefix + `/_find` resp = await this.findWithMango(path, selector, options) } catch (error) { return dontThrowNotFoundError(error) @@ -323,7 +355,7 @@ class FileCollection extends DocumentCollection { const refs = documents.map(d => ({ id: d._id, type: d._type })) const resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/${document._id}/relationships/referenced_by`, + this.prefix + uri`/${document._id}/relationships/referenced_by`, { data: refs } ) return { @@ -351,7 +383,8 @@ class FileCollection extends DocumentCollection { })) const resp = await this.stackClient.fetchJSON( 'DELETE', - uri`/files/${document._id || document.id}/relationships/referenced_by`, + this.prefix + + uri`/${document._id || document.id}/relationships/referenced_by`, { data: refs } ) return { @@ -416,7 +449,7 @@ class FileCollection extends DocumentCollection { const resp = await this.stackClient.fetchJSON( 'DELETE', - uri`/files/${_id}`, + this.prefix + uri`/${_id}`, undefined, { headers: { @@ -443,7 +476,10 @@ class FileCollection extends DocumentCollection { * */ async emptyTrash() { - const resp = await this.stackClient.fetchJSON('DELETE', '/files/trash') + const resp = await this.stackClient.fetchJSON( + 'DELETE', + this.prefix + `/trash` + ) return { data: normalizeFile(resp.data) } @@ -460,7 +496,7 @@ class FileCollection extends DocumentCollection { async restore(id) { const resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/trash/${id}` + this.prefix + uri`/trash/${id}` ) return { data: normalizeFile(resp.data) @@ -488,7 +524,7 @@ class FileCollection extends DocumentCollection { name: sanitizedName, DirID: dirId } - const path = uri`/files/${id}/copy` + const path = this.prefix + uri`/${id}/copy` const url = querystring.buildURL(path, params) const resp = await this.stackClient.fetchJSON('POST', url) @@ -508,7 +544,7 @@ class FileCollection extends DocumentCollection { async deleteFilePermanently(id, { ifMatch = '' } = {}) { const resp = await this.stackClient.fetchJSON( 'PATCH', - uri`/files/${id}`, + this.prefix + uri`/${id}`, { data: { type: 'io.cozy.files', @@ -628,7 +664,9 @@ class FileCollection extends DocumentCollection { if (options.contentLength) { size = String(options.contentLength) } - const path = uri`/files/${dirId}?Name=${name}&Type=file&Executable=${executable}&Encrypted=${encrypted}&MetadataID=${metadataId}&Size=${size}&SourceAccount=${sourceAccount}&SourceAccountIdentifier=${sourceAccountIdentifier}` + const path = + this.prefix + + uri`/${dirId}?Name=${name}&Type=file&Executable=${executable}&Encrypted=${encrypted}&MetadataID=${metadataId}&Size=${size}&SourceAccount=${sourceAccount}&SourceAccountIdentifier=${sourceAccountIdentifier}` return this.doUpload(data, path, options) } @@ -675,7 +713,9 @@ class FileCollection extends DocumentCollection { * (no size limit since we can use the body for that) and after we use the ID. */ let metadataId - let path = uri`/files/${fileId}?Name=${sanitizedName}&Type=file&Executable=${executable}&Encrypted=${encrypted}` + let path = + this.prefix + + uri`/${fileId}?Name=${sanitizedName}&Type=file&Executable=${executable}&Encrypted=${encrypted}` if (metadata) { const meta = await this.createFileMetadata(metadata) metadataId = meta.data.id @@ -695,7 +735,8 @@ class FileCollection extends DocumentCollection { return this.stackClient .fetchJSON( 'POST', - uri`/files/downloads?Id=${id}&Filename=${encodeURIComponent(filename)}` + this.prefix + + uri`/downloads?Id=${id}&Filename=${encodeURIComponent(filename)}` ) .then(this.extractResponseLinkRelated) } @@ -704,15 +745,16 @@ class FileCollection extends DocumentCollection { return this.stackClient .fetchJSON( 'POST', - uri`/files/downloads?VersionId=${versionId}&Filename=${encodeURIComponent( - filename - )}` + this.prefix + + uri`/downloads?VersionId=${versionId}&Filename=${encodeURIComponent( + filename + )}` ) .then(this.extractResponseLinkRelated) } getDownloadLinkByPath(path) { return this.stackClient - .fetchJSON('POST', uri`/files/downloads?Path=${path}`) + .fetchJSON('POST', this.prefix + uri`/downloads?Path=${path}`) .then(this.extractResponseLinkRelated) } @@ -776,7 +818,7 @@ class FileCollection extends DocumentCollection { * */ async fetchFileContentById(id) { - return this.stackClient.fetch('GET', `/files/download/${id}`) + return this.stackClient.fetch('GET', this.prefix + uri`/download/${id}`) } /** @@ -825,15 +867,19 @@ class FileCollection extends DocumentCollection { logger.warn( 'CozyClient FileCollection getArchiveLinkByIds method is deprecated. Use createArchiveLinkByIds instead' ) - const resp = await this.stackClient.fetchJSON('POST', '/files/archive', { - data: { - type: 'io.cozy.archives', - attributes: { - name, - ids + const resp = await this.stackClient.fetchJSON( + 'POST', + this.prefix + `/archive`, + { + data: { + type: 'io.cozy.archives', + attributes: { + name, + ids + } } } - }) + ) return resp.links.related } @@ -848,16 +894,20 @@ class FileCollection extends DocumentCollection { * @returns {Promise} - The archive link */ async createArchiveLinkByIds({ ids, name = 'files', pages }) { - const resp = await this.stackClient.fetchJSON('POST', '/files/archive', { - data: { - type: 'io.cozy.archives', - attributes: { - name, - ids, - ...(pages && { pages }) + const resp = await this.stackClient.fetchJSON( + 'POST', + this.prefix + `/archive`, + { + data: { + type: 'io.cozy.archives', + attributes: { + name, + ids, + ...(pages && { pages }) + } } } - }) + ) return resp.links.related } @@ -915,7 +965,7 @@ class FileCollection extends DocumentCollection { async statById(id, options = {}) { const params = pick(options, ['page[limit]', 'page[skip]', 'page[cursor]']) - const path = uri`/files/${id}` + const path = this.prefix + uri`/${id}` const url = querystring.buildURL(path, params) const resp = await this.stackClient.fetchJSON('GET', url) return { @@ -928,7 +978,7 @@ class FileCollection extends DocumentCollection { async statByPath(path) { const resp = await this.stackClient.fetchJSON( 'GET', - uri`/files/metadata?Path=${path}` + this.prefix + uri`/metadata?Path=${path}` ) return { data: normalizeFile(resp.data), @@ -964,7 +1014,8 @@ class FileCollection extends DocumentCollection { const resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/${dirId}?Name=${safeName}&Type=directory&MetadataID=${metadataId}`, + this.prefix + + uri`/${dirId}?Name=${safeName}&Type=directory&MetadataID=${metadataId}`, undefined, { headers: { @@ -1083,7 +1134,7 @@ class FileCollection extends DocumentCollection { const resp = await this.stackClient.fetchJSON( 'PATCH', - uri`/files/${id}`, + this.prefix + uri`/${id}`, { data: { type: 'io.cozy.files', @@ -1120,7 +1171,7 @@ class FileCollection extends DocumentCollection { async createFileMetadata(attributes) { const resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/upload/metadata`, + this.prefix + uri`/upload/metadata`, { data: { type: 'io.cozy.files.metadata', @@ -1149,7 +1200,7 @@ class FileCollection extends DocumentCollection { async updateMetadataAttribute(id, metadata) { const resp = await this.stackClient.fetchJSON( 'POST', - uri`/files/${id}/versions`, + this.prefix + uri`/${id}/versions`, { data: { type: 'io.cozy.files.metadata', @@ -1396,7 +1447,7 @@ class FileCollection extends DocumentCollection { skip_deleted: opts.skipDeleted, skip_trashed: opts.skipTrashed } - const path = uri`/files/_changes` + const path = this.prefix + `/_changes` const url = querystring.buildURL(path, params) const { last_seq: newLastSeq, @@ -1418,7 +1469,7 @@ class FileCollection extends DocumentCollection { * @returns {IOCozyFolder} Shared Drives directory */ getOrCreateSharedDrivesDirectory() { - return this.stackClient.fetchJSON('POST', '/files/shared-drives') + return this.stackClient.fetchJSON('POST', this.prefix + `/shared-drives`) } }