diff --git a/packages/cozy-client/src/CozyClient.js b/packages/cozy-client/src/CozyClient.js index 243cd28fc7..11669ec522 100644 --- a/packages/cozy-client/src/CozyClient.js +++ b/packages/cozy-client/src/CozyClient.js @@ -1126,7 +1126,7 @@ client.query(Q('io.cozy.bills'))`) return await this.persistVirtualDocument( { _type: 'io.cozy.apps_registry', - _id: 'maintenance', + _id: definition.id, // @ts-ignore cozyPouchData: data }, diff --git a/packages/cozy-stack-client/src/AppsRegistryCollection.js b/packages/cozy-stack-client/src/AppsRegistryCollection.js index 1967a14854..a34da894b9 100644 --- a/packages/cozy-stack-client/src/AppsRegistryCollection.js +++ b/packages/cozy-stack-client/src/AppsRegistryCollection.js @@ -27,6 +27,16 @@ export const normalizeAppFromRegistry = (data, doctype) => { } } +const fetchKonnectorsByChannel = async (channel, doctype, stackClient) => { + const resp = await stackClient.fetchJSON( + 'GET', + `/registry?versionsChannel=${channel}&filter[type]=konnector&limit=500` + ) + return { + data: resp.data.map(data => normalizeAppFromRegistry(data, doctype)) + } +} + /** * Extends `DocumentCollection` API along with specific methods for `io.cozy.apps_registry`. */ @@ -44,6 +54,12 @@ class AppsRegistryCollection extends DocumentCollection { * @throws {FetchError} */ async get(slug) { + if (slug.startsWith('konnectors/')) { + const channel = slug.split('/')[1] + + return fetchKonnectorsByChannel(channel, this.doctype, this.stackClient) + } + const resp = await this.stackClient.fetchJSON( 'GET', `${this.endpoint}${slug}`