import { z } from 'zod';
import { APIResponseSchema } from "../api.js";
import { UserResponseError } from "./util.js";
export const OrganizationSchema = z.object({
    id: z.string().describe('the unique id for the organization'),
    name: z.string().describe('the name of the organization'),
});
export const WhoamiResponse = z.object({
    firstName: z.string().describe('the first name of the user'),
    lastName: z.string().describe('the last name of the user'),
    organizations: z.array(OrganizationSchema).describe('the organizations the user is a member of'),
});
export const WhoamiResponseSchema = APIResponseSchema(WhoamiResponse);
/**
 * Get the current authenticated user information
 *
 * @param client
 * @returns
 */
export async function whoami(client) {
    const resp = await client.get('/cli/auth/user', WhoamiResponseSchema);
    if (resp.success) {
        return resp.data;
    }
    throw new UserResponseError({ message: resp.message });
}
//# sourceMappingURL=whoami.js.map