Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cozy-client/src/CozyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
16 changes: 16 additions & 0 deletions packages/cozy-stack-client/src/AppsRegistryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand All @@ -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}`
Expand Down