Files
speckle-server/packages/server/modules/workspaces/domain/operations.ts
T
Kristaps Fabians Geikins ede566eed9 feat(server): serverInvites refactor + workspace invites CRUD & GQL API (#2530)
* prep for new resources algo

* typescriptifying stuff

* minor types fix

* migrate to resources col

* repo & creation updated, WIP processing/retrieval

* WIP invite processing

* finished finalization refactor

* project invite management

* transformed all invites services

* fixed up projects & core serverinvites resolvers

* test fixes

* WIP workspace create GQL & test

* basic invite creation test works

* a buncha working tests

* more tests

* cancelation tests

* minor invite use refactor

* invite retrieval tasks

* invite use() works as expected

* filtering out broken invites

* enabled invite retrieval by token irregardless of who is it for

* minor adjustments

* tests fix

* test config improvements

* test env adjustment

* extra test case

* making resource access limits harder to ignore

* linter fixes

* eventBus type cleanup

* better generic names

* refactored serverinvites resource migration

* fix(server): better error message in project invite edge case
2024-07-29 14:37:54 +03:00

117 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>
/** Blob */
export type StoreBlob = (args: string) => Promise<string>
/** Events */
export type EmitWorkspaceEvent = <TEvent extends WorkspaceEvents>(args: {
eventName: TEvent
payload: EventBusPayloads[TEvent]
}) => Promise<unknown[]>