feat: add crawl and search ui

This commit is contained in:
Rohit Rajan
2026-01-02 11:54:09 +05:30
parent adfb12e04c
commit 3689eb96bd
8 changed files with 1454 additions and 62 deletions

View File

@@ -335,4 +335,81 @@ export const deleteSchedule = async (id: string): Promise<boolean> => {
console.log(error);
return false;
}
}
}
export const createCrawlRobot = async (
url: string,
name: string,
crawlConfig: {
mode: 'domain' | 'subdomain' | 'path';
limit: number;
maxDepth: number;
includePaths: string[];
excludePaths: string[];
useSitemap: boolean;
followLinks: boolean;
respectRobots: boolean;
}
): Promise<any> => {
try {
const response = await axios.post(
`${apiUrl}/recordings/crawl`,
{
url,
name,
crawlConfig,
},
{
headers: { 'Content-Type': 'application/json' },
withCredentials: true,
}
);
if (response.status === 201) {
return response.data;
} else {
throw new Error('Failed to create crawl robot');
}
} catch (error: any) {
console.error('Error creating crawl robot:', error);
return null;
}
};
export const createSearchRobot = async (
name: string,
searchConfig: {
query: string;
limit: number;
provider: 'google' | 'bing' | 'duckduckgo';
filters?: {
timeRange?: 'day' | 'week' | 'month' | 'year';
location?: string;
lang?: string;
};
mode: 'discover' | 'scrape';
}
): Promise<any> => {
try {
const response = await axios.post(
`${apiUrl}/recordings/search`,
{
name,
searchConfig,
},
{
headers: { 'Content-Type': 'application/json' },
withCredentials: true,
}
);
if (response.status === 201) {
return response.data;
} else {
throw new Error('Failed to create search robot');
}
} catch (error: any) {
console.error('Error creating search robot:', error);
return null;
}
};