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

Function fetchWorkspaces

apps/sim/hooks/queries/workspace.ts:45–71  ·  view source on GitHub ↗
(
  scope: WorkspaceQueryScope = 'active',
  signal?: AbortSignal
)

Source from the content-addressed store, hash-verified

43export type { Workspace, WorkspaceCreationPolicy, WorkspaceMember, WorkspacePermissions }
44
45async function fetchWorkspaces(
46 scope: WorkspaceQueryScope = 'active',
47 signal?: AbortSignal
48): Promise<WorkspacesResponse> {
49 const data = await requestJson(listWorkspacesContract, { query: { scope }, signal })
50 return {
51 workspaces:
52 data.workspaces?.map((workspace: Workspace) => ({
53 ...workspace,
54 organizationId: workspace.organizationId ?? null,
55 workspaceMode: workspace.workspaceMode ?? 'grandfathered_shared',
56 inviteMembersEnabled: workspace.inviteMembersEnabled ?? false,
57 inviteDisabledReason: workspace.inviteDisabledReason ?? null,
58 inviteUpgradeRequired: workspace.inviteUpgradeRequired ?? false,
59 })) || [],
60 lastActiveWorkspaceId:
61 typeof data.lastActiveWorkspaceId === 'string' ? data.lastActiveWorkspaceId : null,
62 creationPolicy: data.creationPolicy
63 ? {
64 ...data.creationPolicy,
65 organizationId: data.creationPolicy.organizationId ?? null,
66 reason: data.creationPolicy.reason ?? null,
67 workspaceMode: data.creationPolicy.workspaceMode ?? 'personal',
68 }
69 : null,
70 }
71}
72
73const selectWorkspaces = (data: WorkspacesResponse): Workspace[] => data.workspaces
74

Callers 3

useWorkspacesQueryFunction · 0.85

Calls 1

requestJsonFunction · 0.90

Tested by

no test coverage detected