import qs from 'qs' import type { ApiClient } from '../../core/ApiClient' import type { ListQuery, Paginated, HasGetMany, HasGetById } from '../../core/types' import type { AuthHistory } from './types' export class AuthHistoryApi implements HasGetMany, HasGetById { private readonly client: ApiClient constructor(client: ApiClient) { this.client = client } /** * Returns a paginated list of authentication events (auth, password_change, logout). Non-admin users can only see their own records. * @permissions authHistory.view */ getMany( query: ListQuery & { paginate: false }, headers?: Record, ): Promise getMany( query?: ListQuery & { paginate?: true }, headers?: Record, ): Promise> getMany( query?: ListQuery, headers?: Record, ): Promise | AuthHistory[]> { const queryString = query ? `?${qs.stringify(query)}` : '' return this.client.get | AuthHistory[]>( `/auth-history${queryString}`, headers, ) } /** * Returns a single authentication event by its ID. Non-admin users can only access their own records. * @permissions authHistory.view */ getById(id: string, headers?: Record): Promise { return this.client.get(`/auth-history/${id}`, headers) } }