Files
speckle-server/packages/server/modules/gatekeeper/services/readOnly.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

26 lines
1.1 KiB
TypeScript

import type { GetWorkspacePlan } from '@/modules/gatekeeper/domain/billing'
import type { GetWorkspacePlanByProjectId } from '@/modules/gatekeeper/domain/operations'
import type { Workspace } from '@/modules/workspacesCore/domain/types'
import { isWorkspacePlanStatusReadOnly } from '@speckle/shared'
export const isWorkspaceReadOnlyFactory =
({ getWorkspacePlan }: { getWorkspacePlan: GetWorkspacePlan }) =>
async ({ workspaceId }: { workspaceId: Workspace['id'] }) => {
const workspacePlan = await getWorkspacePlan({ workspaceId })
// Should never happen
if (!workspacePlan) return true
return isWorkspacePlanStatusReadOnly(workspacePlan.status)
}
export const isProjectReadOnlyFactory =
({
getWorkspacePlanByProjectId
}: {
getWorkspacePlanByProjectId: GetWorkspacePlanByProjectId
}) =>
async ({ projectId }: { projectId: string }) => {
const workspacePlan = await getWorkspacePlanByProjectId({ projectId })
if (!workspacePlan) return false // The project is not in a workspace
return isWorkspacePlanStatusReadOnly(workspacePlan.status)
}