import { WorkspaceEvents } from '@/modules/workspacesCore/domain/events' import { LimitedUserRecord, StreamRecord } from '@/modules/core/helpers/types' import { Workspace, WorkspaceAcl, WorkspaceWithOptionalRole } from '@/modules/workspacesCore/domain/types' import { EventBusPayloads } from '@/modules/shared/services/eventBus' import { WorkspaceRoles } from '@speckle/shared' import { UserWithRole } from '@/modules/core/repositories/users' /** Workspace */ type UpsertWorkspaceArgs = { workspace: Workspace } export type UpsertWorkspace = (args: UpsertWorkspaceArgs) => Promise export type GetWorkspace = (args: { workspaceId: string userId?: string }) => Promise export type GetWorkspaces = (args: { workspaceIds: string[] userId?: string }) => Promise type DeleteWorkspaceArgs = { workspaceId: string } export type DeleteWorkspace = (args: DeleteWorkspaceArgs) => Promise /** Workspace Roles */ type GetWorkspaceCollaboratorsArgs = { workspaceId: string filter?: { /** * Optionally filter by workspace role */ role?: string /** * Optionally filter by user name or email */ search?: string } } export type GetWorkspaceCollaborators = ( args: GetWorkspaceCollaboratorsArgs ) => Promise & { workspaceRole: WorkspaceRoles }>> type DeleteWorkspaceRoleArgs = { workspaceId: string userId: string } export type DeleteWorkspaceRole = ( args: DeleteWorkspaceRoleArgs ) => Promise type GetWorkspaceRolesArgs = { workspaceId: string } /** Get all roles in a given workspaces. */ export type GetWorkspaceRoles = (args: GetWorkspaceRolesArgs) => Promise type GetWorkspaceRoleForUserArgs = { userId: string workspaceId: string } /** Get role for given user in a specific workspace. */ export type GetWorkspaceRoleForUser = ( args: GetWorkspaceRoleForUserArgs ) => Promise type GetWorkspaceRolesForUserArgs = { userId: string } type GetWorkspaceRolesForUserOptions = { /** If provided, limit results to roles in given workspaces. */ workspaceIdFilter?: string[] } /** Get roles for given user across several (or all) workspaces. */ export type GetWorkspaceRolesForUser = ( args: GetWorkspaceRolesForUserArgs, options?: GetWorkspaceRolesForUserOptions ) => Promise export type UpsertWorkspaceRole = (args: WorkspaceAcl) => Promise /** Workspace Projects */ type QueryAllWorkspaceProjectsArgs = { workspaceId: string } export type QueryAllWorkspaceProjects = ( args: QueryAllWorkspaceProjectsArgs ) => AsyncGenerator /** Workspace Project Roles */ type GrantWorkspaceProjectRolesArgs = { projectId: string workspaceId: string } export type GrantWorkspaceProjectRoles = ( args: GrantWorkspaceProjectRolesArgs ) => Promise /** Events */ export type EmitWorkspaceEvent = (args: { eventName: TEvent payload: EventBusPayloads[TEvent] }) => Promise