mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Merge pull request #1382 from mvanhorn/osc/1372-use-canonical-log-types
refactor(use-logs): use canonical log types from contracts/types/log.types
This commit is contained in:
commit
4ab9544a66
2 changed files with 10 additions and 46 deletions
|
|
@ -117,6 +117,8 @@ export const getLogSummaryResponse = logSummary;
|
||||||
export type Log = z.infer<typeof log>;
|
export type Log = z.infer<typeof log>;
|
||||||
export type LogLevelEnum = z.infer<typeof logLevelEnum>;
|
export type LogLevelEnum = z.infer<typeof logLevelEnum>;
|
||||||
export type LogStatusEnum = z.infer<typeof logStatusEnum>;
|
export type LogStatusEnum = z.infer<typeof logStatusEnum>;
|
||||||
|
export type LogLevel = LogLevelEnum;
|
||||||
|
export type LogStatus = LogStatusEnum;
|
||||||
export type LogFilters = z.infer<typeof logFilters>;
|
export type LogFilters = z.infer<typeof logFilters>;
|
||||||
export type CreateLogRequest = z.infer<typeof createLogRequest>;
|
export type CreateLogRequest = z.infer<typeof createLogRequest>;
|
||||||
export type CreateLogResponse = z.infer<typeof createLogResponse>;
|
export type CreateLogResponse = z.infer<typeof createLogResponse>;
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,17 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
|
import type { LogFilters } from "@/contracts/types/log.types";
|
||||||
import { logsApiService } from "@/lib/apis/logs-api.service";
|
import { logsApiService } from "@/lib/apis/logs-api.service";
|
||||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||||
|
|
||||||
export type LogLevel = "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL";
|
export type {
|
||||||
export type LogStatus = "IN_PROGRESS" | "SUCCESS" | "FAILED";
|
Log,
|
||||||
|
LogFilters,
|
||||||
export interface Log {
|
LogLevel,
|
||||||
id: number;
|
LogStatus,
|
||||||
level: LogLevel;
|
LogSummary,
|
||||||
status: LogStatus;
|
} from "@/contracts/types/log.types";
|
||||||
message: string;
|
|
||||||
source?: string;
|
|
||||||
log_metadata?: Record<string, unknown>;
|
|
||||||
created_at: string;
|
|
||||||
search_space_id: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogFilters {
|
|
||||||
search_space_id?: number;
|
|
||||||
level?: LogLevel;
|
|
||||||
status?: LogStatus;
|
|
||||||
source?: string;
|
|
||||||
start_date?: string;
|
|
||||||
end_date?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogSummary {
|
|
||||||
total_logs: number;
|
|
||||||
time_window_hours: number;
|
|
||||||
by_status: Record<string, number>;
|
|
||||||
by_level: Record<string, number>;
|
|
||||||
by_source: Record<string, number>;
|
|
||||||
active_tasks: Array<{
|
|
||||||
id: number;
|
|
||||||
task_name: string;
|
|
||||||
message: string;
|
|
||||||
started_at: string;
|
|
||||||
source?: string;
|
|
||||||
document_id?: number;
|
|
||||||
}>;
|
|
||||||
recent_failures: Array<{
|
|
||||||
id: number;
|
|
||||||
task_name: string;
|
|
||||||
message: string;
|
|
||||||
failed_at: string;
|
|
||||||
source?: string;
|
|
||||||
error_details?: string;
|
|
||||||
}>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useLogs(searchSpaceId?: number, filters: LogFilters = {}) {
|
export function useLogs(searchSpaceId?: number, filters: LogFilters = {}) {
|
||||||
const filtersKey = JSON.stringify(filters);
|
const filtersKey = JSON.stringify(filters);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue