MCPcopy Index your code
hub / github.com/simstudioai/sim / ensureWorkspaceAccess

Function ensureWorkspaceAccess

apps/sim/lib/copilot/tools/handlers/access.ts:46–68  ·  view source on GitHub ↗
(
  workspaceId: string,
  userId: string,
  level: 'read' | 'write' | 'admin' = 'read'
)

Source from the content-addressed store, hash-verified

44}
45
46export async function ensureWorkspaceAccess(
47 workspaceId: string,
48 userId: string,
49 level: 'read' | 'write' | 'admin' = 'read'
50): Promise<void> {
51 const access = await checkWorkspaceAccess(workspaceId, userId)
52 if (!access.exists || !access.hasAccess) {
53 throw new Error(`Workspace ${workspaceId} not found`)
54 }
55
56 if (level === 'read') return
57
58 if (level === 'admin') {
59 if (!access.canAdmin) {
60 throw new Error('Admin access required for this workspace')
61 }
62 return
63 }
64
65 if (!access.canWrite) {
66 throw new Error('Write or admin access required for this workspace')
67 }
68}

Callers 15

executeOAuthGetAuthLinkFunction · 0.90
executeCreateWorkflowFunction · 0.90
executeCreateFolderFunction · 0.90
executeMoveFolderFunction · 0.90
executeGenerateApiKeyFunction · 0.90
executeDeleteFolderFunction · 0.90
executeRenameFolderFunction · 0.90
executeFunction · 0.90

Calls 1

checkWorkspaceAccessFunction · 0.90

Tested by

no test coverage detected