diff --git a/docs/api/cozy-client.md b/docs/api/cozy-client.md
index 3ebb15d1d1..cef1cb2e8b 100644
--- a/docs/api/cozy-client.md
+++ b/docs/api/cozy-client.md
@@ -45,7 +45,7 @@ from a Cozy. QueryDefinition
s are sent to links.
const schema = new Schema({
+const schema = new Schema({
todos: {
attributes: {
label: {
@@ -61,29 +61,6 @@ from a Cozy. QueryDefinition
s are sent to links.
-## Members
-
-
-- target :
object
-The original document declaring the relationship
-
-- name :
string
-The name of the relationship.
-
-- doctype :
string
-Doctype of the relationship
-
-- get :
function
-Returns the document from the store
-
-- save :
function
-Saves the relationship in store.
-
-- dispatch :
function
-Dispatch an action on the store.
-
-
-
## Constants
@@ -99,7 +76,7 @@ from a Cozy. QueryDefinition
s are sent to links.
- updateHasManyItem
Updates a relationship item with the relationship name and id
-- windowInterface :
WindowInterface
+- win :
CordovaWindow
- generateWebLink ⇒
string
generateWebLink - Construct a link to a web app
@@ -225,16 +202,18 @@ example.
- getReferencedFolder ⇒
Promise.<IOCozyFolder>
Returns the most recent folder referenced by the given document
-- getRootPath
+- win :
CordovaWindow
+
+- getRootPath ⇒
string
Get root path according the OS
- getTemporaryRootPath
Get the temporary root path according to the OS
-- getCozyPath
+- getCozyPath ⇒
string
Get Cozy path according to the OS
-- getEntry
+- getEntry ⇒
Promise.<FilesystemEntry>
Get entry of a path in the cordova.file location
- getCozyEntry
@@ -282,6 +261,9 @@ example.
- fetchURL ⇒
Promise.<string>
Fetch and build an URL to open a note.
+- saveTimeSeries
+Helper to save a time series document.
+
- triggerStates
Trigger states come from /jobs/triggers
@@ -310,13 +292,7 @@ is loading.
## Functions
-- query(queryDefinition)
-Performs a query to retrieve relationship documents.
-
-- mutate()
-Performs a mutation on the relationship.
-
-- query() ⇒
QueryState
| QueryDefinition
+- query() ⇒
QueryState
| QueryDefinition
- createClientInteractive(clientOptions)
Creates a client with interactive authentication.
@@ -345,7 +321,7 @@ if there are N queries, only 1 extra level of nesting is introduced.
Takes the same arguments as fetchJSON
Returns an object with the same keys { data, fetchStatus, error } as useQuery
-- useQuery(queryDefinition, options) ⇒
object
+- useQuery(queryDefinition, options) ⇒
UseQueryReturnValue
Fetches a queryDefinition and returns the queryState
- sanitizeCategories()
@@ -406,14 +382,14 @@ internal store updated.
- Relation :
object
-- WindowInterface :
object
-
- ClientOptions :
object
- CozyAccount :
object
- QualificationAttributes :
object
+- FilesystemEntry :
object
+
- Document :
object
Couchdb document like an io.cozy.files
@@ -432,9 +408,8 @@ on the recipient's cozy. It can be used to make an UI distinction between th
both situation.
- TimeSeries
-Helper to save a time series document.
-
-- TimeSeriesJSONAPI ⇒
TimeSeriesJSONAPI
+
+- TimeSeriesJSONAPI ⇒
Promise.<TimeSeriesJSONAPI>
Helper to retrieve time series by their date interval and source.
The starting date must be greater or equal while the ending date must
be stricly less than the given startDate and endDate parameters.
@@ -455,6 +430,14 @@ be stricly less than the given startDate and endDate parameters.
- Manifest :
object
+- QueryFetchStatus :
"loading"
| "loaded"
| "pending"
| "failed"
+
+- QueryState :
object
+
+- FetchMoreAble :
object
+
+- UseQueryReturnValue :
QueryState
| FetchMoreAble
+
- Reference :
object
A reference to a document (special case of a relationship used between photos and albums)
https://docs.cozy.io/en/cozy-doctypes/docs/io.cozy.files/#references
@@ -474,6 +457,14 @@ be stricly less than the given startDate and endDate parameters.
- ClientError :
object
+- FilePlugin
+
+- InAppBrowser
+
+- Cordova
+
+- CordovaWindow
+
- CancelablePromise :
Promise
- Wrapper ⇒
function
@@ -485,7 +476,7 @@ be stricly less than the given startDate and endDate parameters.
- Association
Example: The schema defines an author
relationship :
-const BOOK_SCHEMA = {
+const BOOK_SCHEMA = {
relationships: {
author: 'has-one'
}
@@ -493,7 +484,7 @@ be stricly less than the given startDate and endDate parameters.
Hydrated books
will have the author
association instance under the author
key.
Accessing hydratedBook.author.data
gives you the author from the store, for example :
-{
+{
"name": "St-Exupery",
"firstName": "Antoine",
"_id": "antoine"
@@ -503,7 +494,7 @@ Accessing hydratedBook.author.data
gives you the author from the st
For example, here since we use the default has-one
relationship, the relationship data
is stored in the relationships
attribute of the original document (in our case here, our book
would be
-{
+{
"title": "Le petit prince",
"relationships": {
"author": {
@@ -517,7 +508,7 @@ would be
In the case of an "in-place" relationship, the relationship data is stored directly under the attribute named
by the relationship (in our case author
). Our book would be
-{
+{
"title": "Le petit prince",
"author": "antoine"
}
@@ -616,11 +607,63 @@ the hydrated document (.data method). View components will access
* [Association](#Association)
* _instance_
+ * [.target](#Association+target) : object
+ * [.name](#Association+name) : string
+ * [.doctype](#Association+doctype) : string
+ * [.get](#Association+get) : function
+ * [.save](#Association+save) : function
+ * [.dispatch](#Association+dispatch) : function
* [.raw](#Association+raw) ⇒ object
* [.data](#Association+data) ⇒ object
+ * [.query(queryDefinition)](#Association+query)
+ * [.mutate()](#Association+mutate)
* _static_
- * [.query()](#Association.query) ⇒ [QueryDefinition
](#QueryDefinition)
+ * [.query()](#Association.query) ⇒ [QueryDefinition
](#QueryDefinition) \| [QueryState
](#QueryState)
+
+
+
+### association.target : object
+The original document declaring the relationship
+
+**Kind**: instance property of [Association
](#Association)
+
+
+### association.name : string
+The name of the relationship.
+
+**Kind**: instance property of [Association
](#Association)
+**Example**
+```js
+'author'
+```
+
+
+### association.doctype : string
+Doctype of the relationship
+
+**Kind**: instance property of [Association
](#Association)
+**Example**
+```js
+'io.cozy.authors'
+```
+
+
+### association.get : function
+Returns the document from the store
+
+**Kind**: instance property of [Association
](#Association)
+
+
+### association.save : function
+Saves the relationship in store.
+
+**Kind**: instance property of [Association
](#Association)
+
+
+### association.dispatch : function
+Dispatch an action on the store.
+**Kind**: instance property of [Association
](#Association)
### association.raw ⇒ object
@@ -689,9 +732,26 @@ const book = {
Derived `Association`s need to implement this method.
**Kind**: instance property of [Association
](#Association)
+
+
+### association.query(queryDefinition)
+Performs a query to retrieve relationship documents.
+
+**Kind**: instance method of [Association
](#Association)
+
+| Param | Type |
+| --- | --- |
+| queryDefinition | [QueryDefinition
](#QueryDefinition) |
+
+
+
+### association.mutate()
+Performs a mutation on the relationship.
+
+**Kind**: instance method of [Association
](#Association)
-### Association.query() ⇒ [QueryDefinition
](#QueryDefinition)
+### Association.query() ⇒ [QueryDefinition
](#QueryDefinition) \| [QueryState
](#QueryState)
Derived `Association`s need to implement this method.
**Kind**: static method of [Association
](#Association)
@@ -901,7 +961,7 @@ Responsible for
* [new CozyClient(rawOptions)](#new_CozyClient_new)
* _instance_
* [.storeAccesors](#CozyClient+storeAccesors) : object
- * [.fetchQueryAndGetFromState](#CozyClient+fetchQueryAndGetFromState) ⇒ Promise.<QueryState>
+ * [.fetchQueryAndGetFromState](#CozyClient+fetchQueryAndGetFromState) ⇒ [Promise.<QueryState>
](#QueryState)
* [.emit()](#CozyClient+emit)
* [.registerPlugin()](#CozyClient+registerPlugin)
* [.login([options])](#CozyClient+login) ⇒ Promise
@@ -919,7 +979,7 @@ Responsible for
* [.getRelationshipStoreAccessors()](#CozyClient+getRelationshipStoreAccessors)
* [.getCollectionFromState(type)](#CozyClient+getCollectionFromState) ⇒ [Array.<CozyClientDocument>
](#CozyClientDocument)
* [.getDocumentFromState(type, id)](#CozyClient+getDocumentFromState) ⇒ [CozyClientDocument
](#CozyClientDocument)
- * [.getQueryFromState(id, options)](#CozyClient+getQueryFromState) ⇒ QueryState
+ * [.getQueryFromState(id, options)](#CozyClient+getQueryFromState) ⇒ [QueryState
](#QueryState)
* [.register(cozyURL)](#CozyClient+register) ⇒ object
* [.startOAuthFlow(openURLCallback)](#CozyClient+startOAuthFlow) ⇒ Promise.<object>
* [.renewAuthorization()](#CozyClient+renewAuthorization) ⇒ object
@@ -947,20 +1007,38 @@ Responsible for
| --- | --- | --- |
| rawOptions | [ClientOptions
](#ClientOptions) | Options |
+**Example**
+```js
+const client = new CozyClient({
+ schema: {
+ todos: {
+ doctype: 'io.cozy.todos',
+ relationships: {
+ authors: {
+ type: 'has-many',
+ doctype: 'io.cozy.persons'
+ }
+ }
+ }
+ }
+})
+```
+
+Cozy-Client will automatically call `this.login()` if provided with a token and an uri
### cozyClient.storeAccesors : object
**Kind**: instance property of [CozyClient
](#CozyClient)
-### cozyClient.fetchQueryAndGetFromState ⇒ Promise.<QueryState>
+### cozyClient.fetchQueryAndGetFromState ⇒ [Promise.<QueryState>
](#QueryState)
Executes a query and returns the results from internal store.
Can be useful in pure JS context (without React)
Has a behavior close to or useQuery
**Kind**: instance property of [CozyClient
](#CozyClient)
-**Returns**: Promise.<QueryState>
- Query state
+**Returns**: [Promise.<QueryState>
](#QueryState) - Query state
| Param | Type | Description |
| --- | --- | --- |
@@ -1257,11 +1335,11 @@ Get a document from the internal store.
-### cozyClient.getQueryFromState(id, options) ⇒ QueryState
+### cozyClient.getQueryFromState(id, options) ⇒ [QueryState
](#QueryState)
Get a query from the internal store.
**Kind**: instance method of [CozyClient
](#CozyClient)
-**Returns**: QueryState
- - Query state or null if it does not exist.
+**Returns**: [QueryState
](#QueryState) - - Query state or null if it does not exist.
| Param | Type | Description |
| --- | --- | --- |
@@ -1455,140 +1533,6 @@ CozyClient.registerHook('io.cozy.bank.accounts', 'before:destroy', () => {
console.log('A io.cozy.bank.accounts is being destroyed')
})
```
-
-
-## Qualification
-This class is used to create document Qualification, i.e. metadata
-attributes used to describe the document.
-The qualifications model is stored in the assets, associating
-labels to attributes, namely: purpose, sourceCategory, sourceSubCategory
-and subjects.
-A qualification can be customized accordingly to rules detailed in
-the checkValueAttributes method.
-
-**Kind**: global class
-
-* [Qualification](#Qualification)
- * [new exports.Qualification(label, attributes)](#new_Qualification_new)
- * _instance_
- * [.label](#Qualification+label) : string
- * [.purpose](#Qualification+purpose) : string
- * [.checkAttributes(attributes)](#Qualification+checkAttributes)
- * [.setPurpose(purpose)](#Qualification+setPurpose) ⇒ [Qualification
](#Qualification)
- * [.setSourceCategory(sourceCategory)](#Qualification+setSourceCategory) ⇒ [Qualification
](#Qualification)
- * [.setSourceSubCategory(sourceSubCategory)](#Qualification+setSourceSubCategory) ⇒ [Qualification
](#Qualification)
- * [.setSubjects(subjects)](#Qualification+setSubjects) ⇒ [Qualification
](#Qualification)
- * [.toQualification()](#Qualification+toQualification) ⇒ object
- * _static_
- * [.getByLabel(label)](#Qualification.getByLabel) ⇒ [Qualification
](#Qualification)
-
-
-
-### new exports.Qualification(label, attributes)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| label | string
| The qualification label |
-| attributes | [QualificationAttributes
](#QualificationAttributes) | Qualification's attributes |
-
-
-
-### qualification.label : string
-- The qualification label.
-
-**Kind**: instance property of [Qualification
](#Qualification)
-
-
-### qualification.purpose : string
-- The document purpose.
-
-**Kind**: instance property of [Qualification
](#Qualification)
-
-
-### qualification.checkAttributes(attributes)
-Check the given qualification attributes respects the following rules:
- - For the given label, if a purpose, sourceCategory or sourceSubCategory
- attribute is defined in the model, it must match the given qualification.
- - If not defined in the model for the label, a custom purpose, sourceCategory or
- sourceSubCategory value can be defined, if it exist in their respective
- known values list.
- - For the given label, if subjects are defined in the model, they must be included
- in the given qualification.
- - If extra subjects are set, they should exist in the known values.
-
-**Kind**: instance method of [Qualification
](#Qualification)
-
-| Param | Type | Description |
-| --- | --- | --- |
-| attributes | object
| The qualification attributes to check |
-
-
-
-### qualification.setPurpose(purpose) ⇒ [Qualification
](#Qualification)
-Set purpose to the qualification.
-
-**Kind**: instance method of [Qualification
](#Qualification)
-**Returns**: [Qualification
](#Qualification) - The Qualification object.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| purpose | Array
| The purpose to set. |
-
-
-
-### qualification.setSourceCategory(sourceCategory) ⇒ [Qualification
](#Qualification)
-Set sourceCategory to the qualification.
-
-**Kind**: instance method of [Qualification
](#Qualification)
-**Returns**: [Qualification
](#Qualification) - The Qualification object.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| sourceCategory | Array
| The sourceCategory to set. |
-
-
-
-### qualification.setSourceSubCategory(sourceSubCategory) ⇒ [Qualification
](#Qualification)
-Set sourceSubCategory to the qualification.
-
-**Kind**: instance method of [Qualification
](#Qualification)
-**Returns**: [Qualification
](#Qualification) - The Qualification object.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| sourceSubCategory | Array
| The sourceSubCategory to set. |
-
-
-
-### qualification.setSubjects(subjects) ⇒ [Qualification
](#Qualification)
-Set subjects to the qualification.
-
-**Kind**: instance method of [Qualification
](#Qualification)
-**Returns**: [Qualification
](#Qualification) - The Qualification object.
-
-| Param | Type | Description |
-| --- | --- | --- |
-| subjects | Array
| The subjects to set. |
-
-
-
-### qualification.toQualification() ⇒ object
-Returns the qualification attributes
-
-**Kind**: instance method of [Qualification
](#Qualification)
-**Returns**: object
- The qualification attributes
-
-
-### Qualification.getByLabel(label) ⇒ [Qualification
](#Qualification)
-Returns the qualification associated to a label.
-
-**Kind**: static method of [Qualification
](#Qualification)
-**Returns**: [Qualification
](#Qualification) - - The qualification
-
-| Param | Type | Description |
-| --- | --- | --- |
-| label | string
| The label to qualify |
-
## QueryDefinition ⇐ object
@@ -1890,50 +1834,6 @@ Returns the relationship for a given doctype/name
Validates a document considering the descriptions in schema.attributes.
**Kind**: instance method of [Schema
](#Schema)
-
-
-## target : object
-The original document declaring the relationship
-
-**Kind**: global variable
-
-
-## name : string
-The name of the relationship.
-
-**Kind**: global variable
-**Example**
-```js
-'author'
-```
-
-
-## doctype : string
-Doctype of the relationship
-
-**Kind**: global variable
-**Example**
-```js
-'io.cozy.authors'
-```
-
-
-## get : function
-Returns the document from the store
-
-**Kind**: global variable
-
-
-## save : function
-Saves the relationship in store.
-
-**Kind**: global variable
-
-
-## dispatch : function
-Dispatch an action on the store.
-
-**Kind**: global variable
## getHasManyItem
@@ -1988,9 +1888,9 @@ Updates a relationship item with the relationship name and id
| relItemId | string
| Id of the relationship item |
| updater | function
| receives the current relationship item and should return an updated version. Merge should be used in the updater if previous relationship item fields are to be kept. |
-
+
-## windowInterface : [WindowInterface
](#WindowInterface)
+## win : [CordovaWindow
](#CordovaWindow)
**Kind**: global constant
@@ -2506,9 +2406,13 @@ Returns the most recent folder referenced by the given document
| client | [CozyClient
](#CozyClient) | cozy-client instance |
| document | [CozyClientDocument
](#CozyClientDocument) | Document to get references from |
+
+
+## win : [CordovaWindow
](#CordovaWindow)
+**Kind**: global constant
-## getRootPath
+## getRootPath ⇒ string
Get root path according the OS
**Kind**: global constant
@@ -2520,13 +2424,13 @@ Get the temporary root path according to the OS
**Kind**: global constant
-## getCozyPath
+## getCozyPath ⇒ string
Get Cozy path according to the OS
**Kind**: global constant
-## getEntry
+## getEntry ⇒ [Promise.<FilesystemEntry>
](#FilesystemEntry)
Get entry of a path in the cordova.file location
**Kind**: global constant
@@ -2716,6 +2620,18 @@ Fetch and build an URL to open a note.
| client | object
| CozyClient instance |
| file | object
| io.cozy.file object |
+
+
+## saveTimeSeries
+Helper to save a time series document.
+
+**Kind**: global constant
+
+| Param | Type | Description |
+| --- | --- | --- |
+| client | object
| The CozyClient instance |
+| timeseriesOption | [TimeSeries
](#TimeSeries) | The time series to save |
+
## triggerStates
@@ -2835,24 +2751,7 @@ Returns whether a query has been loaded at least once
**Kind**: global constant
-## query(queryDefinition)
-Performs a query to retrieve relationship documents.
-
-**Kind**: global function
-
-| Param | Type |
-| --- | --- |
-| queryDefinition | [QueryDefinition
](#QueryDefinition) |
-
-
-
-## mutate()
-Performs a mutation on the relationship.
-
-**Kind**: global function
-
-
-## query() ⇒ QueryState
\| [QueryDefinition
](#QueryDefinition)
+## query() ⇒ [QueryState
](#QueryState) \| [QueryDefinition
](#QueryDefinition)
**Kind**: global function
@@ -2942,7 +2841,7 @@ Returns an object with the same keys { data, fetchStatus, error } as useQuery
**Kind**: global function
-## useQuery(queryDefinition, options) ⇒ object
+## useQuery(queryDefinition, options) ⇒ [UseQueryReturnValue
](#UseQueryReturnValue)
Fetches a queryDefinition and returns the queryState
**Kind**: global function
@@ -3143,18 +3042,6 @@ HOC to provide mutations to components. Needs client in context or as prop.
| _id | string
| id of the relation |
| _type | string
| doctype of the relation |
-
-
-## WindowInterface : object
-**Kind**: global typedef
-**Properties**
-
-| Name | Type |
-| --- | --- |
-| SafariViewController | object
|
-| cordova | object
|
-| handleOpenURL | function
|
-
## ClientOptions : object
@@ -3197,6 +3084,10 @@ HOC to provide mutations to components. Needs client in context or as prop.
| [sourceSubCategory] | string
| The sub-activity field of the document source. |
| [subjects] | Array.<string>
| On what is about the document. |
+
+
+## FilesystemEntry : object
+**Kind**: global typedef
## Document : object
@@ -3259,31 +3150,29 @@ both situation.
## TimeSeries
-Helper to save a time series document.
-
**Kind**: global typedef
-**Attributes**: dataType {String} - The type of time series, e.g. 'electricity'
-**Attributes**: startDate {date} - The starting date of the series
-**Attributes**: endType {date} - The starting date of the series
-**Attributes**: source {String} - The data source, e.g. 'enedis.fr'
-**Attributes**: theme {String} - The theme used to group time series, e.g. 'energy'
-**Attributes**: series {Array} - An array of objects representing the time series
+**Properties**
-| Param | Type | Description |
+| Name | Type | Description |
| --- | --- | --- |
-| client | object
| The CozyClient instance |
-| | [TimeSeries
](#TimeSeries) | The time series to save |
+| dataType | String
| The type of time series, e.g. 'electricity' |
+| startDate | Date
| The starting date of the series |
+| endDate | Date
| The end date of the series |
+| endType | Date
| The starting date of the series |
+| source | String
| The data source, e.g. 'enedis.fr' |
+| theme | String
| The theme used to group time series, e.g. 'energy' |
+| series | Array
| An array of objects representing the time series |
-## TimeSeriesJSONAPI ⇒ [TimeSeriesJSONAPI
](#TimeSeriesJSONAPI)
+## TimeSeriesJSONAPI ⇒ [Promise.<TimeSeriesJSONAPI>
](#TimeSeriesJSONAPI)
Helper to retrieve time series by their date interval and source.
The starting date must be greater or equal while the ending date must
be stricly less than the given startDate and endDate parameters.
**Kind**: global typedef
-**Returns**: [TimeSeriesJSONAPI
](#TimeSeriesJSONAPI) - The TimeSeries found by the query in JSON-API format
+**Returns**: [Promise.<TimeSeriesJSONAPI>
](#TimeSeriesJSONAPI) - The TimeSeries found by the query in JSON-API format
| Param | Type | Description |
| --- | --- | --- |
@@ -3350,6 +3239,43 @@ Setups a client suitable for testing
## Manifest : object
**Kind**: global typedef
+
+
+## QueryFetchStatus : "loading"
\| "loaded"
\| "pending"
\| "failed"
+**Kind**: global typedef
+
+
+## QueryState : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| id | string
|
+| definition | [QueryDefinition
](#QueryDefinition) |
+| fetchStatus | [QueryFetchStatus
](#QueryFetchStatus) |
+| lastFetch | number
|
+| lastUpdate | number
|
+| lastError | Error
|
+| hasMore | boolean
|
+| count | number
|
+| data | object
\| Array
|
+| bookmark | string
|
+
+
+
+## FetchMoreAble : object
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| fetchMore | function
|
+
+
+
+## UseQueryReturnValue : [QueryState
](#QueryState) \| [FetchMoreAble
](#FetchMoreAble)
+**Kind**: global typedef
## Reference : object
@@ -3435,6 +3361,54 @@ An io.cozy.files document
| --- | --- |
| [status] | string
|
+
+
+## FilePlugin
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| [externalRootDirectory] | object
|
+| [cacheDirectory] | object
|
+| [externalCacheDirectory] | object
|
+| [dataDirectory] | object
|
+
+
+
+## InAppBrowser
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| open | function
|
+
+
+
+## Cordova
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| file | [FilePlugin
](#FilePlugin) |
+| InAppBrowser | [InAppBrowser
](#InAppBrowser) |
+| plugins | object
|
+
+
+
+## CordovaWindow
+**Kind**: global typedef
+**Properties**
+
+| Name | Type |
+| --- | --- |
+| cordova | [Cordova
](#Cordova) |
+| SafariViewController | object
|
+| resolveLocalFileSystemURL | function
|
+| handleOpenURL | function
|
+
## CancelablePromise : Promise