mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Merge remote-tracking branch 'upstream/dev' into refactor/indexing-pipelines
This commit is contained in:
commit
17091edb77
104 changed files with 4944 additions and 1319 deletions
|
|
@ -13,7 +13,7 @@ export interface Log {
|
|||
status: LogStatus;
|
||||
message: string;
|
||||
source?: string;
|
||||
log_metadata?: Record<string, any>;
|
||||
log_metadata?: Record<string, unknown>;
|
||||
created_at: string;
|
||||
search_space_id: number;
|
||||
}
|
||||
|
|
@ -52,8 +52,9 @@ export interface LogSummary {
|
|||
}
|
||||
|
||||
export function useLogs(searchSpaceId?: number, filters: LogFilters = {}) {
|
||||
// Memoize filters to prevent infinite re-renders
|
||||
const memoizedFilters = useMemo(() => filters, [JSON.stringify(filters)]);
|
||||
const filtersKey = JSON.stringify(filters);
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: stable serialized key used intentionally
|
||||
const memoizedFilters = useMemo(() => filters, [filtersKey]);
|
||||
|
||||
const buildQueryParams = useCallback(
|
||||
(customFilters: LogFilters = {}) => {
|
||||
|
|
@ -62,22 +63,22 @@ export function useLogs(searchSpaceId?: number, filters: LogFilters = {}) {
|
|||
const allFilters = { ...memoizedFilters, ...customFilters };
|
||||
|
||||
if (allFilters.search_space_id) {
|
||||
params["search_space_id"] = allFilters.search_space_id.toString();
|
||||
params.search_space_id = allFilters.search_space_id.toString();
|
||||
}
|
||||
if (allFilters.level) {
|
||||
params["level"] = allFilters.level;
|
||||
params.level = allFilters.level;
|
||||
}
|
||||
if (allFilters.status) {
|
||||
params["status"] = allFilters.status;
|
||||
params.status = allFilters.status;
|
||||
}
|
||||
if (allFilters.source) {
|
||||
params["source"] = allFilters.source;
|
||||
params.source = allFilters.source;
|
||||
}
|
||||
if (allFilters.start_date) {
|
||||
params["start_date"] = allFilters.start_date;
|
||||
params.start_date = allFilters.start_date;
|
||||
}
|
||||
if (allFilters.end_date) {
|
||||
params["end_date"] = allFilters.end_date;
|
||||
params.end_date = allFilters.end_date;
|
||||
}
|
||||
|
||||
return params;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
import { authenticatedFetch, getBearerToken, handleUnauthorized } from "@/lib/auth-utils";
|
||||
import { authenticatedFetch } from "@/lib/auth-utils";
|
||||
|
||||
export interface SearchSourceConnector {
|
||||
id: number;
|
||||
|
|
@ -7,7 +7,7 @@ export interface SearchSourceConnector {
|
|||
connector_type: string;
|
||||
is_indexable: boolean;
|
||||
last_indexed_at: string | null;
|
||||
config: Record<string, any>;
|
||||
config: Record<string, unknown>;
|
||||
search_space_id: number;
|
||||
user_id?: string;
|
||||
created_at?: string;
|
||||
|
|
@ -20,7 +20,7 @@ export interface ConnectorSourceItem {
|
|||
id: number;
|
||||
name: string;
|
||||
type: string;
|
||||
sources: any[];
|
||||
sources: unknown[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -60,6 +60,44 @@ export const useSearchSourceConnectors = (lazy: boolean = false, searchSpaceId?:
|
|||
},
|
||||
]);
|
||||
|
||||
const updateConnectorSourceItems = useCallback((currentConnectors: SearchSourceConnector[]) => {
|
||||
const defaultConnectors: ConnectorSourceItem[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Crawled URL",
|
||||
type: "CRAWLED_URL",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "File",
|
||||
type: "FILE",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Extension",
|
||||
type: "EXTENSION",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Youtube Video",
|
||||
type: "YOUTUBE_VIDEO",
|
||||
sources: [],
|
||||
},
|
||||
];
|
||||
|
||||
const apiConnectors: ConnectorSourceItem[] = currentConnectors.map((connector, index) => ({
|
||||
id: 1000 + index,
|
||||
name: connector.name,
|
||||
type: connector.connector_type,
|
||||
sources: [],
|
||||
}));
|
||||
|
||||
setConnectorSourceItems([...defaultConnectors, ...apiConnectors]);
|
||||
}, []);
|
||||
|
||||
const fetchConnectors = useCallback(
|
||||
async (spaceId?: number) => {
|
||||
if (isLoaded && lazy) return; // Avoid redundant calls in lazy mode
|
||||
|
|
@ -100,7 +138,7 @@ export const useSearchSourceConnectors = (lazy: boolean = false, searchSpaceId?:
|
|||
setIsLoading(false);
|
||||
}
|
||||
},
|
||||
[isLoaded, lazy]
|
||||
[isLoaded, lazy, updateConnectorSourceItems]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -120,47 +158,6 @@ export const useSearchSourceConnectors = (lazy: boolean = false, searchSpaceId?:
|
|||
[fetchConnectors, searchSpaceId]
|
||||
);
|
||||
|
||||
// Update connector source items when connectors change
|
||||
const updateConnectorSourceItems = (currentConnectors: SearchSourceConnector[]) => {
|
||||
// Start with the default hardcoded connectors
|
||||
const defaultConnectors: ConnectorSourceItem[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Crawled URL",
|
||||
type: "CRAWLED_URL",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "File",
|
||||
type: "FILE",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Extension",
|
||||
type: "EXTENSION",
|
||||
sources: [],
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "Youtube Video",
|
||||
type: "YOUTUBE_VIDEO",
|
||||
sources: [],
|
||||
},
|
||||
];
|
||||
|
||||
// Add the API connectors
|
||||
const apiConnectors: ConnectorSourceItem[] = currentConnectors.map((connector, index) => ({
|
||||
id: 1000 + index, // Use a high ID to avoid conflicts with hardcoded IDs
|
||||
name: connector.name,
|
||||
type: connector.connector_type,
|
||||
sources: [],
|
||||
}));
|
||||
|
||||
setConnectorSourceItems([...defaultConnectors, ...apiConnectors]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new search source connector
|
||||
* @param connectorData - The connector data (excluding search_space_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue