feat(api): add listing workspace users

This commit is contained in:
Karol Sójko
2022-10-11 12:20:58 +02:00
parent 7a43e2d368
commit fb41f651ec
30 changed files with 190 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
import { WorkspaceApiServiceInterface } from '@standardnotes/api'
import { Uuid, WorkspaceType } from '@standardnotes/common'
import { Workspace } from '@standardnotes/models'
import { Uuid, WorkspaceAccessLevel, WorkspaceType } from '@standardnotes/common'
import { Workspace, WorkspaceUser } from '@standardnotes/models'
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { AbstractService } from '../Service/AbstractService'
@@ -14,6 +14,20 @@ export class WorkspaceManager extends AbstractService implements WorkspaceClient
super(internalEventBus)
}
async listWorkspaceUsers(dto: { workspaceUuid: string }): Promise<{ users: WorkspaceUser[] }> {
try {
const result = await this.workspaceApiService.listWorkspaceUsers(dto)
if (result.data.error !== undefined) {
return { users: [] }
}
return result.data
} catch (error) {
return { users: [] }
}
}
async listWorkspaces(): Promise<{ ownedWorkspaces: Workspace[]; joinedWorkspaces: Workspace[] }> {
try {
const result = await this.workspaceApiService.listWorkspaces()
@@ -50,7 +64,7 @@ export class WorkspaceManager extends AbstractService implements WorkspaceClient
async inviteToWorkspace(dto: {
inviteeEmail: string
workspaceUuid: Uuid
accessLevel: string
accessLevel: WorkspaceAccessLevel
}): Promise<{ uuid: string } | null> {
try {
const result = await this.workspaceApiService.inviteToWorkspace(dto)