import { z } from "zod"; import { apiGet } from "@/api/api"; import { API_PATHS } from "@/api/api-paths"; import { handleApiResponse } from "@/api/handle-api-response"; export const UNEXPECTED_PERMISSIONS_RESPONSE = "The server sent an unexpected permissions response."; const effectivePermissionsSchema = z.object({ permissions: z.array(z.string()) }); /** Keys the signed-in user holds after role defaults and their individual overrides. */ export async function getMyPermissions(): Promise { const data = await apiGet(API_PATHS.teamMember.myPermissions); const result = effectivePermissionsSchema.safeParse(handleApiResponse(data)); if (!result.success) throw new Error(UNEXPECTED_PERMISSIONS_RESPONSE); return result.data.permissions; }