diff --git a/src/mapeo-project.js b/src/mapeo-project.js index 68e12d21a..99055b38c 100644 --- a/src/mapeo-project.js +++ b/src/mapeo-project.js @@ -227,6 +227,9 @@ export class MapeoProject { getDeviceInfo: async (deviceId) => { return this.#dataTypes.deviceInfo.getByDocId(deviceId) }, + getManyDeviceInfo: async () => { + return this.#dataTypes.deviceInfo.getMany() + }, }, }) diff --git a/src/member-api.js b/src/member-api.js index 4e6754a3e..8eefd175a 100644 --- a/src/member-api.js +++ b/src/member-api.js @@ -19,6 +19,7 @@ export class MemberApi extends TypedEmitter { * @param {Object} opts.queries * @param {() => Promise} opts.queries.getProjectInfo * @param {(deviceId: string) => Promise} opts.queries.getDeviceInfo + * @param {() => Promise>} opts.queries.getManyDeviceInfo * */ constructor({ capabilities, encryptionKeys, projectKey, rpc, queries }) { @@ -64,4 +65,12 @@ export class MemberApi extends TypedEmitter { const deviceInfo = await this.#queries.getDeviceInfo(deviceId) return { deviceId, name: deviceInfo.name } } + + /** + * @returns {Promise>} + */ + async getMany() { + const devices = await this.#queries.getManyDeviceInfo() + return devices.map(({ docId, name }) => ({ deviceId: docId, name })) + } }