feat(history): add query history filters
This commit is contained in:
1 parent
1c7576537a
commit
d16ba82d5a
22 files changed
+1324
-40
No files matched your search
@@ -490,6 +490,8 @@ export const vectorListCollections = forward("vectorListCollections");
|
||||
// History
|
||||
export const saveHistory = forward("saveHistory");
|
||||
export const loadHistory = forward("loadHistory");
|
||||
export const searchHistory = forward("searchHistory");
|
||||
export const loadHistoryConnectionOptions = forward("loadHistoryConnectionOptions");
|
||||
export const loadRedisHistory = forward("loadRedisHistory");
|
||||
export const clearHistory = forward("clearHistory");
|
||||
export const clearRedisHistory = forward("clearRedisHistory");
|
||||
@@ -579,6 +581,12 @@ export type {
|
||||
KvDeleteResponse,
|
||||
MongoDocumentResult,
|
||||
HistoryEntry,
|
||||
HistoryConnectionFilter,
|
||||
HistoryDatabaseFilter,
|
||||
HistoryCursor,
|
||||
HistorySearchRequest,
|
||||
HistorySearchResult,
|
||||
HistoryConnectionOption,
|
||||
SqlFileStatus,
|
||||
SqlFileRequest,
|
||||
SqlFilePreview,
|
||||
|
||||
@@ -78,6 +78,9 @@ import type {
|
||||
MongoCollectionStatsResult,
|
||||
MongoGridFsBucketInfo,
|
||||
HistoryEntry,
|
||||
HistorySearchRequest,
|
||||
HistorySearchResult,
|
||||
HistoryConnectionOption,
|
||||
SqlFileRequest,
|
||||
SqlFilePreview,
|
||||
SqlFileProgress,
|
||||
@@ -2251,6 +2254,14 @@ export async function loadHistory(limit: number, offset: number, activityKind?:
|
||||
return get(`/api/history?${qs({ limit, offset, activity_kind: activityKind })}`);
|
||||
}
|
||||
|
||||
export async function searchHistory(request: HistorySearchRequest): Promise<HistorySearchResult> {
|
||||
return post("/api/history/search", request);
|
||||
}
|
||||
|
||||
export async function loadHistoryConnectionOptions(): Promise<HistoryConnectionOption[]> {
|
||||
return get("/api/history/options");
|
||||
}
|
||||
|
||||
export async function loadRedisHistory(limit = 100, offset = 0): Promise<HistoryEntry[]> {
|
||||
return loadHistory(limit, offset, "redis_command");
|
||||
}
|
||||
|
||||
@@ -2050,6 +2050,42 @@ export interface HistoryEntry {
|
||||
details_json?: string | null;
|
||||
}
|
||||
|
||||
export interface HistoryConnectionFilter {
|
||||
connection_id: string;
|
||||
connection_name: string;
|
||||
}
|
||||
|
||||
export interface HistoryDatabaseFilter extends HistoryConnectionFilter {
|
||||
database: string;
|
||||
}
|
||||
|
||||
export interface HistoryCursor {
|
||||
executed_at: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface HistorySearchRequest {
|
||||
search_text: string;
|
||||
connections: HistoryConnectionFilter[];
|
||||
databases: HistoryDatabaseFilter[];
|
||||
activity_kind?: string;
|
||||
success?: boolean;
|
||||
started_at?: string;
|
||||
ended_at?: string;
|
||||
cursor?: HistoryCursor;
|
||||
limit: number;
|
||||
}
|
||||
|
||||
export interface HistorySearchResult {
|
||||
entries: HistoryEntry[];
|
||||
next_cursor?: HistoryCursor | null;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface HistoryConnectionOption extends HistoryConnectionFilter {
|
||||
databases: string[];
|
||||
}
|
||||
|
||||
export async function saveHistory(entry: HistoryEntry): Promise<void> {
|
||||
return invoke("save_history", { entry });
|
||||
}
|
||||
@@ -2058,6 +2094,14 @@ export async function loadHistory(limit: number, offset: number, activityKind?:
|
||||
return invoke("load_history", { limit, offset, activityKind: activityKind ?? null });
|
||||
}
|
||||
|
||||
export async function searchHistory(request: HistorySearchRequest): Promise<HistorySearchResult> {
|
||||
return invoke("search_history", { request });
|
||||
}
|
||||
|
||||
export async function loadHistoryConnectionOptions(): Promise<HistoryConnectionOption[]> {
|
||||
return invoke("load_history_connection_options");
|
||||
}
|
||||
|
||||
export async function loadRedisHistory(limit = 100, offset = 0): Promise<HistoryEntry[]> {
|
||||
return loadHistory(limit, offset, "redis_command");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { HistoryConnectionFilter, HistoryDatabaseFilter } from "@/lib/backend/api";
|
||||
|
||||
export function historyConnectionHasSelectedDatabase(connection: HistoryConnectionFilter, databases: HistoryDatabaseFilter[]): boolean {
|
||||
return databases.some((database) => {
|
||||
if (!database.database) return false;
|
||||
if (connection.connection_id || database.connection_id) {
|
||||
return Boolean(connection.connection_id) && connection.connection_id === database.connection_id;
|
||||
}
|
||||
return Boolean(connection.connection_name) && connection.connection_name === database.connection_name;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user