Files
speckle-server/packages/server/modules/workspaces/repositories/projects.ts
T
Chuck Driesler 35e99d6ee7 feat(workspaces): emit who will be added to workspace for a given project move (#4332)
* wip

* feat(workspaces): preflight service wip

* feat(workspaces): move project to workspace dry run

* fix(workspaces): add tests and refine query

* chore(workspaces): gqlgen
2025-04-07 10:27:08 +01:00

28 lines
1.1 KiB
TypeScript

import { StreamAcl, Users } from '@/modules/core/dbSchema'
import { StreamAclRecord } from '@/modules/core/helpers/types'
import { UserRecord } from '@/modules/core/helpers/userHelper'
import { IntersectProjectCollaboratorsAndWorkspaceCollaborators } from '@/modules/workspaces/domain/operations'
import { WorkspaceAcl } from '@/modules/workspacesCore/helpers/db'
import { Knex } from 'knex'
const tables = {
streamAcl: (db: Knex) => db.table<StreamAclRecord>('stream_acl')
}
export const intersectProjectCollaboratorsAndWorkspaceCollaboratorsFactory =
(deps: { db: Knex }): IntersectProjectCollaboratorsAndWorkspaceCollaborators =>
async ({ projectId, workspaceId }) => {
return await tables
.streamAcl(deps.db)
.select<UserRecord[]>(...Users.cols)
.join(Users.name, Users.col.id, StreamAcl.col.userId)
.where(StreamAcl.col.resourceId, projectId)
.except((builder) => {
return builder
.select(...Users.cols)
.from(WorkspaceAcl.name)
.join(Users.name, Users.col.id, WorkspaceAcl.col.userId)
.where(WorkspaceAcl.col.workspaceId, workspaceId)
})
}