Files
speckle-server/packages/server/modules/workspaces/domain/operations.ts
T
Gergő Jedlicska ee6e5e22b1 gergo/eventBus (#2498)
* feat(eventBus): WIP event bus typescript wizardy

* feat(eventBus): final eventbus setup with all the typescript foo

* fix(workspaces): fix workspace core imports

* test(workspaces): fix expected events name

* test(workspaces): fix tests
2024-07-12 15:35:40 +02:00

76 lines
1.8 KiB
TypeScript

import {
WorkspaceEvents,
WorkspaceEventsPayloads
} from '@/modules/workspacesCore/domain/events'
import { Workspace, WorkspaceAcl } from '@/modules/workspacesCore/domain/types'
/** Workspace */
type UpsertWorkspaceArgs = {
workspace: Workspace
}
export type UpsertWorkspace = (args: UpsertWorkspaceArgs) => Promise<void>
type GetWorkspaceArgs = {
workspaceId: string
}
export type GetWorkspace = (args: GetWorkspaceArgs) => Promise<Workspace | null>
/** WorkspaceRole */
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>
/** Blob */
export type StoreBlob = (args: string) => Promise<string>
/** Events */
export type EmitWorkspaceEvent = <TEvent extends WorkspaceEvents>(args: {
eventName: TEvent
payload: WorkspaceEventsPayloads[TEvent]
}) => Promise<unknown[]>