175 lines
4.0 KiB
TypeScript
175 lines
4.0 KiB
TypeScript
// Tipos da API (espelham backend/internal/httpapi/dto.go e api/openapi.yaml).
|
|
|
|
export type Role = "owner" | "admin" | "viewer";
|
|
export type UserStatus = "pending" | "active" | "disabled";
|
|
export type NotificationStatus = "scheduled" | "sending" | "sent" | "failed" | "cancelled" | "expired";
|
|
export type NotificationType = "entrada2" | "saida2";
|
|
export type DayStatus = "awaiting" | "no_points" | "working" | "not_working" | "finished";
|
|
|
|
export interface Problem {
|
|
type: string;
|
|
title: string;
|
|
status: number;
|
|
code?: string;
|
|
errors?: { field: string; message: string }[];
|
|
}
|
|
|
|
export interface Account {
|
|
id: number;
|
|
username: string;
|
|
role: Role;
|
|
user_id: number | null;
|
|
disabled: boolean;
|
|
locked_until: string | null;
|
|
last_login_at: string | null;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface Me {
|
|
account: Account;
|
|
expires_at: string;
|
|
}
|
|
|
|
export interface User {
|
|
id: number;
|
|
telegram_chat_id: number;
|
|
display_name: string;
|
|
status: UserStatus;
|
|
is_bot_admin: boolean;
|
|
notifications_enabled: boolean;
|
|
paused_reason: string | null;
|
|
timezone: string;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface UserSummary extends User {
|
|
has_credential: boolean;
|
|
credential_validated: boolean;
|
|
consecutive_failures: number;
|
|
custom_window: boolean;
|
|
}
|
|
|
|
export interface QueryWindow {
|
|
query_window_start: string;
|
|
query_window_end: string;
|
|
day_check_deadline: string;
|
|
no_points_recheck_until: string;
|
|
}
|
|
|
|
export interface Schedule {
|
|
lunch_minutes: number;
|
|
daily_work_minutes: number;
|
|
entrada2_lead_minutes: number;
|
|
saida2_lead_minutes: number;
|
|
window: QueryWindow | null;
|
|
}
|
|
|
|
export interface Credential {
|
|
api_email: string;
|
|
validated: boolean;
|
|
last_validated_at: string | null;
|
|
last_error: string | null;
|
|
consecutive_failures: number;
|
|
last_failure_at: string | null;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface Day {
|
|
day: string;
|
|
status: DayStatus;
|
|
zero_point_checks: number;
|
|
last_point_count: number;
|
|
next_check_at: string | null;
|
|
resumed_by: string | null;
|
|
}
|
|
|
|
export interface UserDetail {
|
|
user: User;
|
|
schedule: Schedule;
|
|
credential: Credential | null;
|
|
today: Day;
|
|
effective_window: QueryWindow;
|
|
custom_window: boolean;
|
|
}
|
|
|
|
export interface Today {
|
|
day: string;
|
|
timezone: string;
|
|
points: string[];
|
|
invalid: boolean;
|
|
overtime: boolean;
|
|
entrada2_at: string | null;
|
|
saida2_at: string | null;
|
|
saida2_error?: string;
|
|
day_state: Day;
|
|
window: QueryWindow;
|
|
custom_window: boolean;
|
|
}
|
|
|
|
export interface Notification {
|
|
id: number;
|
|
user_id: number;
|
|
user_name?: string;
|
|
reference_date: string;
|
|
type: NotificationType;
|
|
scheduled_at: string;
|
|
predicted_at: string;
|
|
status: NotificationStatus;
|
|
attempts: number;
|
|
sent_at: string | null;
|
|
error_message: string | null;
|
|
}
|
|
|
|
export interface AuditLog {
|
|
id: number;
|
|
occurred_at: string;
|
|
source: string;
|
|
actor_user_id: number | null;
|
|
actor_user_name: string | null;
|
|
actor_account: number | null;
|
|
actor_username: string | null;
|
|
target_user_id: number | null;
|
|
target_user_name: string | null;
|
|
event_type: string;
|
|
success: boolean;
|
|
details: Record<string, unknown>;
|
|
}
|
|
|
|
export interface Holiday {
|
|
day: string;
|
|
name: string;
|
|
source: string;
|
|
}
|
|
|
|
export interface Dashboard {
|
|
users_by_status: Record<string, number>;
|
|
notifications_enabled: number;
|
|
paused_by_api_failures: number;
|
|
today_by_status: Record<string, number>;
|
|
failed_last_7_days: number;
|
|
expired_last_7_days: number;
|
|
custom_windows: number;
|
|
outage_since: string | null;
|
|
holiday_fallback_day: string | null;
|
|
today: string;
|
|
}
|
|
|
|
export interface Settings {
|
|
window: QueryWindow;
|
|
reconciliation_minutes: number;
|
|
dispatch_minutes: number;
|
|
late_tolerance_minutes: number;
|
|
api_failure_threshold: number;
|
|
slow_check_minutes: number;
|
|
}
|
|
|
|
export interface WindowPreview {
|
|
errors: { field: string; message: string }[];
|
|
max_queries_per_user: number;
|
|
typical_queries_per_user: number;
|
|
day_off_queries_per_user: number;
|
|
affected_users: number;
|
|
affected_days: number;
|
|
custom_window_users: number;
|
|
}
|