web: Clean up error handling. Prep for permission checks. - Add clearer reporting for API and network errors. - Tidy error checking. - Partial type safety for events.
41 lines
828 B
TypeScript
41 lines
828 B
TypeScript
import { Event } from "@goauthentik/api";
|
|
|
|
export interface EventUser {
|
|
pk: number;
|
|
email?: string;
|
|
username: string;
|
|
on_behalf_of?: EventUser;
|
|
is_anonymous?: boolean;
|
|
}
|
|
|
|
export interface EventGeo {
|
|
city?: string;
|
|
country?: string;
|
|
continent?: string;
|
|
}
|
|
|
|
export interface EventModel {
|
|
pk: string;
|
|
name: string;
|
|
app: string;
|
|
model_name: string;
|
|
}
|
|
|
|
export interface EventRequest {
|
|
path: string;
|
|
method: string;
|
|
}
|
|
|
|
export type EventContextProperty = EventModel | EventGeo | string | number | string[] | undefined;
|
|
|
|
// TODO: Events should have more specific types.
|
|
export interface EventContext {
|
|
[key: string]: EventContext | EventContextProperty;
|
|
geo?: EventGeo;
|
|
}
|
|
|
|
export interface EventWithContext extends Event {
|
|
user: EventUser;
|
|
context: EventContext;
|
|
}
|