Files
speckle-server/packages/server/modules/workspaces/domain/operations.ts
T
Chuck Driesler c97ccb48a1 fix(workspaces): support workspace logos as base64 strings (#2556)
* fix(workspaces): support workspace logos as base64 strings

* fix(workspaces): fix those testsss

* fix(workspaces): migration! and more test fixes
2024-08-02 13:04:20 +02:00

113 lines
2.8 KiB
TypeScript

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<void>
export type GetWorkspace = (args: {
workspaceId: string
userId?: string
}) => Promise<WorkspaceWithOptionalRole | null>
export type GetWorkspaces = (args: {
workspaceIds: string[]
userId?: string
}) => Promise<WorkspaceWithOptionalRole[]>
/** Workspace Roles */
export type GetWorkspaceCollaborators = (args: {
workspaceId: string
/**
* Optionally filter by role
*/
role?: WorkspaceRoles
}) => Promise<
Array<UserWithRole<LimitedUserRecord> & { workspaceRole: WorkspaceRoles }>
>
type DeleteWorkspaceRoleArgs = {
workspaceId: string
userId: string
}
export type DeleteWorkspaceRole = (
args: DeleteWorkspaceRoleArgs
) => Promise<WorkspaceAcl | null>
type GetWorkspaceRolesArgs = {
workspaceId: string
}
/** Get all roles in a given workspaces. */
export type GetWorkspaceRoles = (args: GetWorkspaceRolesArgs) => Promise<WorkspaceAcl[]>
type GetWorkspaceRoleForUserArgs = {
userId: string
workspaceId: string
}
/** Get role for given user in a specific workspace. */
export type GetWorkspaceRoleForUser = (
args: GetWorkspaceRoleForUserArgs
) => Promise<WorkspaceAcl | null>
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<WorkspaceAcl[]>
export type UpsertWorkspaceRole = (args: WorkspaceAcl) => Promise<void>
/** Workspace Projects */
type GetAllWorkspaceProjectsForUserArgs = {
userId: string
workspaceId: string
}
export type GetAllWorkspaceProjectsForUser = (
args: GetAllWorkspaceProjectsForUserArgs
) => Promise<StreamRecord[]>
/** Workspace Project Roles */
type GrantWorkspaceProjectRolesArgs = {
projectId: string
workspaceId: string
}
export type GrantWorkspaceProjectRoles = (
args: GrantWorkspaceProjectRolesArgs
) => Promise<void>
/** Events */
export type EmitWorkspaceEvent = <TEvent extends WorkspaceEvents>(args: {
eventName: TEvent
payload: EventBusPayloads[TEvent]
}) => Promise<unknown[]>