( scope: WorkspaceQueryScope = 'active', signal?: AbortSignal )
| 43 | export type { Workspace, WorkspaceCreationPolicy, WorkspaceMember, WorkspacePermissions } |
| 44 | |
| 45 | async 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 | |
| 73 | const selectWorkspaces = (data: WorkspacesResponse): Workspace[] => data.workspaces |
| 74 |
no test coverage detected