mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-02 04:12:47 +02:00
feat: Update SearxNG connector form validation, enhance connector connect view with additional properties, and refine type handling in connector dialog for improved schema compliance.
This commit is contained in:
parent
21146485e6
commit
4d6186a43a
5 changed files with 17 additions and 8 deletions
|
|
@ -27,7 +27,8 @@ const searxngFormSchema = z.object({
|
||||||
message: "Connector name must be at least 3 characters.",
|
message: "Connector name must be at least 3 characters.",
|
||||||
}),
|
}),
|
||||||
host: z
|
host: z
|
||||||
.string({ required_error: "Host is required." })
|
.string()
|
||||||
|
.min(1, { message: "Host is required." })
|
||||||
.url({ message: "Enter a valid SearxNG host URL (e.g. https://searxng.example.org)." }),
|
.url({ message: "Enter a valid SearxNG host URL (e.g. https://searxng.example.org)." }),
|
||||||
api_key: z.string().optional(),
|
api_key: z.string().optional(),
|
||||||
engines: z.string().optional(),
|
engines: z.string().optional(),
|
||||||
|
|
@ -37,7 +38,7 @@ const searxngFormSchema = z.object({
|
||||||
.string()
|
.string()
|
||||||
.regex(/^[0-2]?$/, { message: "SafeSearch must be 0, 1, or 2." })
|
.regex(/^[0-2]?$/, { message: "SafeSearch must be 0, 1, or 2." })
|
||||||
.optional(),
|
.optional(),
|
||||||
verify_ssl: z.boolean().default(true),
|
verify_ssl: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type SearxngFormValues = z.infer<typeof searxngFormSchema>;
|
type SearxngFormValues = z.infer<typeof searxngFormSchema>;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,12 @@ interface ConnectorConnectViewProps {
|
||||||
is_indexable: boolean;
|
is_indexable: boolean;
|
||||||
last_indexed_at: null;
|
last_indexed_at: null;
|
||||||
periodic_indexing_enabled: boolean;
|
periodic_indexing_enabled: boolean;
|
||||||
indexing_frequency_minutes: null;
|
indexing_frequency_minutes: number | null;
|
||||||
next_scheduled_at: null;
|
next_scheduled_at: null;
|
||||||
|
startDate?: Date;
|
||||||
|
endDate?: Date;
|
||||||
|
periodicEnabled?: boolean;
|
||||||
|
frequencyMinutes?: string;
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
isSubmitting: boolean;
|
isSubmitting: boolean;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export type IndexingConfigState = z.infer<typeof indexingConfigStateSchema>;
|
||||||
* Schema for frequency minutes (must be one of the allowed values)
|
* Schema for frequency minutes (must be one of the allowed values)
|
||||||
*/
|
*/
|
||||||
export const frequencyMinutesSchema = z.enum(["15", "60", "360", "720", "1440", "10080"], {
|
export const frequencyMinutesSchema = z.enum(["15", "60", "360", "720", "1440", "10080"], {
|
||||||
errorMap: () => ({ message: "Invalid frequency value" }),
|
message: "Invalid frequency value",
|
||||||
});
|
});
|
||||||
|
|
||||||
export type FrequencyMinutes = z.infer<typeof frequencyMinutesSchema>;
|
export type FrequencyMinutes = z.infer<typeof frequencyMinutesSchema>;
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ export const useConnectorDialog = () => {
|
||||||
|
|
||||||
// Handle OAuth connection
|
// Handle OAuth connection
|
||||||
const handleConnectOAuth = useCallback(
|
const handleConnectOAuth = useCallback(
|
||||||
async (connector: (typeof OAUTH_CONNECTORS)[0]) => {
|
async (connector: (typeof OAUTH_CONNECTORS)[number]) => {
|
||||||
if (!searchSpaceId || !connector.authEndpoint) return;
|
if (!searchSpaceId || !connector.authEndpoint) return;
|
||||||
|
|
||||||
// Set connecting state immediately to disable button and show spinner
|
// Set connecting state immediately to disable button and show spinner
|
||||||
|
|
@ -368,9 +368,13 @@ export const useConnectorDialog = () => {
|
||||||
// Extract UI-only fields before sending to backend
|
// Extract UI-only fields before sending to backend
|
||||||
const { startDate, endDate, periodicEnabled, frequencyMinutes, ...connectorData } = formData;
|
const { startDate, endDate, periodicEnabled, frequencyMinutes, ...connectorData } = formData;
|
||||||
|
|
||||||
// Create connector
|
// Create connector - ensure types match the schema
|
||||||
const newConnector = await createConnector({
|
const newConnector = await createConnector({
|
||||||
data: connectorData,
|
data: {
|
||||||
|
...connectorData,
|
||||||
|
connector_type: connectorData.connector_type as EnumConnectorName,
|
||||||
|
next_scheduled_at: connectorData.next_scheduled_at as string | null,
|
||||||
|
},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
search_space_id: searchSpaceId,
|
search_space_id: searchSpaceId,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ interface AllConnectorsTabProps {
|
||||||
connectedTypes: Set<string>;
|
connectedTypes: Set<string>;
|
||||||
connectingId: string | null;
|
connectingId: string | null;
|
||||||
allConnectors: SearchSourceConnector[] | undefined;
|
allConnectors: SearchSourceConnector[] | undefined;
|
||||||
onConnectOAuth: (connector: (typeof OAUTH_CONNECTORS)[0]) => void;
|
onConnectOAuth: (connector: (typeof OAUTH_CONNECTORS)[number]) => void;
|
||||||
onConnectNonOAuth?: (connectorType: string) => void;
|
onConnectNonOAuth?: (connectorType: string) => void;
|
||||||
onCreateWebcrawler?: () => void;
|
onCreateWebcrawler?: () => void;
|
||||||
onManage?: (connector: SearchSourceConnector) => void;
|
onManage?: (connector: SearchSourceConnector) => void;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue