mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Merge branch 'dev' into google-drive-connector
Merge in dev
This commit is contained in:
commit
c5c61a2c6b
76 changed files with 3237 additions and 961 deletions
159
surfsense_web/contracts/types/connector.types.ts
Normal file
159
surfsense_web/contracts/types/connector.types.ts
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
import { z } from "zod";
|
||||
import { paginationQueryParams } from ".";
|
||||
|
||||
export const searchSourceConnectorTypeEnum = z.enum([
|
||||
"SERPER_API",
|
||||
"TAVILY_API",
|
||||
"SEARXNG_API",
|
||||
"LINKUP_API",
|
||||
"BAIDU_SEARCH_API",
|
||||
"SLACK_CONNECTOR",
|
||||
"NOTION_CONNECTOR",
|
||||
"GITHUB_CONNECTOR",
|
||||
"LINEAR_CONNECTOR",
|
||||
"DISCORD_CONNECTOR",
|
||||
"JIRA_CONNECTOR",
|
||||
"CONFLUENCE_CONNECTOR",
|
||||
"CLICKUP_CONNECTOR",
|
||||
"GOOGLE_CALENDAR_CONNECTOR",
|
||||
"GOOGLE_GMAIL_CONNECTOR",
|
||||
"AIRTABLE_CONNECTOR",
|
||||
"LUMA_CONNECTOR",
|
||||
"ELASTICSEARCH_CONNECTOR",
|
||||
"WEBCRAWLER_CONNECTOR",
|
||||
"BOOKSTACK_CONNECTOR",
|
||||
]);
|
||||
|
||||
export const searchSourceConnector = z.object({
|
||||
id: z.number(),
|
||||
name: z.string(),
|
||||
connector_type: searchSourceConnectorTypeEnum,
|
||||
is_indexable: z.boolean(),
|
||||
last_indexed_at: z.string().nullable(),
|
||||
config: z.record(z.string(), z.any()),
|
||||
periodic_indexing_enabled: z.boolean(),
|
||||
indexing_frequency_minutes: z.number().nullable(),
|
||||
next_scheduled_at: z.string().nullable(),
|
||||
search_space_id: z.number(),
|
||||
user_id: z.string(),
|
||||
created_at: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Get connectors
|
||||
*/
|
||||
export const getConnectorsRequest = z.object({
|
||||
queryParams: paginationQueryParams
|
||||
.pick({ skip: true, limit: true })
|
||||
.extend({
|
||||
search_space_id: z.number().or(z.string()).nullish(),
|
||||
})
|
||||
.nullish(),
|
||||
});
|
||||
|
||||
export const getConnectorsResponse = z.array(searchSourceConnector);
|
||||
|
||||
/**
|
||||
* Get connector
|
||||
*/
|
||||
export const getConnectorRequest = searchSourceConnector.pick({ id: true });
|
||||
|
||||
export const getConnectorResponse = searchSourceConnector;
|
||||
|
||||
/**
|
||||
* Create connector
|
||||
*/
|
||||
export const createConnectorRequest = z.object({
|
||||
data: searchSourceConnector.pick({
|
||||
name: true,
|
||||
connector_type: true,
|
||||
is_indexable: true,
|
||||
last_indexed_at: true,
|
||||
config: true,
|
||||
periodic_indexing_enabled: true,
|
||||
indexing_frequency_minutes: true,
|
||||
next_scheduled_at: true,
|
||||
}),
|
||||
queryParams: z.object({
|
||||
search_space_id: z.number().or(z.string()),
|
||||
}),
|
||||
});
|
||||
|
||||
export const createConnectorResponse = searchSourceConnector;
|
||||
|
||||
/**
|
||||
* Update connector
|
||||
*/
|
||||
export const updateConnectorRequest = z.object({
|
||||
id: z.number(),
|
||||
data: searchSourceConnector
|
||||
.pick({
|
||||
name: true,
|
||||
connector_type: true,
|
||||
is_indexable: true,
|
||||
last_indexed_at: true,
|
||||
config: true,
|
||||
periodic_indexing_enabled: true,
|
||||
indexing_frequency_minutes: true,
|
||||
next_scheduled_at: true,
|
||||
})
|
||||
.partial(),
|
||||
});
|
||||
|
||||
export const updateConnectorResponse = searchSourceConnector;
|
||||
|
||||
/**
|
||||
* Delete connector
|
||||
*/
|
||||
export const deleteConnectorRequest = searchSourceConnector.pick({ id: true });
|
||||
|
||||
export const deleteConnectorResponse = z.object({
|
||||
message: z.literal("Search source connector deleted successfully"),
|
||||
});
|
||||
|
||||
/**
|
||||
* Index connector
|
||||
*/
|
||||
export const indexConnectorRequest = z.object({
|
||||
connector_id: z.number(),
|
||||
queryParams: z.object({
|
||||
search_space_id: z.number().or(z.string()),
|
||||
start_date: z.string().optional(),
|
||||
end_date: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const indexConnectorResponse = z.object({
|
||||
message: z.string(),
|
||||
connector_id: z.number(),
|
||||
search_space_id: z.number(),
|
||||
indexing_from: z.string(),
|
||||
indexing_to: z.string(),
|
||||
});
|
||||
|
||||
/**
|
||||
* List GitHub repositories
|
||||
*/
|
||||
export const listGitHubRepositoriesRequest = z.object({
|
||||
github_pat: z.string(),
|
||||
});
|
||||
|
||||
export const listGitHubRepositoriesResponse = z.array(z.record(z.string(), z.any()));
|
||||
|
||||
// Inferred types
|
||||
export type SearchSourceConnectorType = z.infer<typeof searchSourceConnectorTypeEnum>;
|
||||
export type SearchSourceConnector = z.infer<typeof searchSourceConnector>;
|
||||
export type GetConnectorsRequest = z.infer<typeof getConnectorsRequest>;
|
||||
export type GetConnectorsResponse = z.infer<typeof getConnectorsResponse>;
|
||||
export type GetConnectorRequest = z.infer<typeof getConnectorRequest>;
|
||||
export type GetConnectorResponse = z.infer<typeof getConnectorResponse>;
|
||||
export type CreateConnectorRequest = z.infer<typeof createConnectorRequest>;
|
||||
export type CreateConnectorResponse = z.infer<typeof createConnectorResponse>;
|
||||
export type UpdateConnectorRequest = z.infer<typeof updateConnectorRequest>;
|
||||
export type UpdateConnectorResponse = z.infer<typeof updateConnectorResponse>;
|
||||
export type DeleteConnectorRequest = z.infer<typeof deleteConnectorRequest>;
|
||||
export type DeleteConnectorResponse = z.infer<typeof deleteConnectorResponse>;
|
||||
export type IndexConnectorRequest = z.infer<typeof indexConnectorRequest>;
|
||||
export type IndexConnectorResponse = z.infer<typeof indexConnectorResponse>;
|
||||
export type ListGitHubRepositoriesRequest = z.infer<typeof listGitHubRepositoriesRequest>;
|
||||
export type ListGitHubRepositoriesResponse = z.infer<typeof listGitHubRepositoriesResponse>;
|
||||
134
surfsense_web/contracts/types/log.types.ts
Normal file
134
surfsense_web/contracts/types/log.types.ts
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
import { z } from "zod";
|
||||
import { paginationQueryParams } from ".";
|
||||
|
||||
/**
|
||||
* ENUMS
|
||||
*/
|
||||
export const logLevelEnum = z.enum(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]);
|
||||
|
||||
export const logStatusEnum = z.enum(["IN_PROGRESS", "SUCCESS", "FAILED"]);
|
||||
|
||||
/**
|
||||
* Base log schema
|
||||
*/
|
||||
export const log = z.object({
|
||||
id: z.number(),
|
||||
level: logLevelEnum,
|
||||
status: logStatusEnum,
|
||||
message: z.string(),
|
||||
source: z.string().nullable().optional(),
|
||||
log_metadata: z.record(z.string(), z.any()).nullable().optional(),
|
||||
created_at: z.string(),
|
||||
search_space_id: z.number(),
|
||||
});
|
||||
|
||||
export const logBase = log.omit({ id: true, created_at: true });
|
||||
|
||||
/**
|
||||
* Create log
|
||||
*/
|
||||
export const createLogRequest = logBase.extend({ search_space_id: z.number() });
|
||||
export const createLogResponse = log;
|
||||
|
||||
/**
|
||||
* Update log
|
||||
*/
|
||||
export const updateLogRequest = logBase.partial();
|
||||
export const updateLogResponse = log;
|
||||
|
||||
/**
|
||||
* Delete log
|
||||
*/
|
||||
export const deleteLogRequest = z.object({ id: z.number() });
|
||||
export const deleteLogResponse = z.object({
|
||||
message: z.string().default("Log deleted successfully"),
|
||||
});
|
||||
|
||||
/**
|
||||
* Get logs (list)
|
||||
*/
|
||||
export const logFilters = z.object({
|
||||
search_space_id: z.number().optional(),
|
||||
level: logLevelEnum.optional(),
|
||||
status: logStatusEnum.optional(),
|
||||
source: z.string().optional(),
|
||||
start_date: z.string().optional(),
|
||||
end_date: z.string().optional(),
|
||||
});
|
||||
|
||||
export const getLogsRequest = z.object({
|
||||
queryParams: paginationQueryParams
|
||||
.extend({
|
||||
search_space_id: z.number().optional(),
|
||||
level: logLevelEnum.optional(),
|
||||
status: logStatusEnum.optional(),
|
||||
source: z.string().optional(),
|
||||
start_date: z.string().optional(),
|
||||
end_date: z.string().optional(),
|
||||
})
|
||||
.nullish(),
|
||||
});
|
||||
export const getLogsResponse = z.array(log);
|
||||
|
||||
/**
|
||||
* Get single log
|
||||
*/
|
||||
export const getLogRequest = z.object({ id: z.number() });
|
||||
export const getLogResponse = log;
|
||||
|
||||
/**
|
||||
* Log summary (used for summary dashboard)
|
||||
*/
|
||||
export const logActiveTask = z.object({
|
||||
id: z.number(),
|
||||
task_name: z.string(),
|
||||
message: z.string(),
|
||||
started_at: z.string(),
|
||||
source: z.string().nullable().optional(),
|
||||
document_id: z.number().nullable().optional(),
|
||||
});
|
||||
export const logFailure = z.object({
|
||||
id: z.number(),
|
||||
task_name: z.string(),
|
||||
message: z.string(),
|
||||
failed_at: z.string(),
|
||||
source: z.string().nullable().optional(),
|
||||
error_details: z.string().nullable().optional(),
|
||||
});
|
||||
export const logSummary = z.object({
|
||||
total_logs: z.number(),
|
||||
time_window_hours: z.number(),
|
||||
by_status: z.record(z.string(), z.number()),
|
||||
by_level: z.record(z.string(), z.number()),
|
||||
by_source: z.record(z.string(), z.number()),
|
||||
active_tasks: z.array(logActiveTask),
|
||||
recent_failures: z.array(logFailure),
|
||||
});
|
||||
export const getLogSummaryRequest = z.object({
|
||||
search_space_id: z.number(),
|
||||
hours: z.number().optional(),
|
||||
});
|
||||
export const getLogSummaryResponse = logSummary;
|
||||
|
||||
/**
|
||||
* Typescript types
|
||||
*/
|
||||
export type Log = z.infer<typeof log>;
|
||||
export type LogLevelEnum = z.infer<typeof logLevelEnum>;
|
||||
export type LogStatusEnum = z.infer<typeof logStatusEnum>;
|
||||
export type LogFilters = z.infer<typeof logFilters>;
|
||||
export type CreateLogRequest = z.infer<typeof createLogRequest>;
|
||||
export type CreateLogResponse = z.infer<typeof createLogResponse>;
|
||||
export type UpdateLogRequest = z.infer<typeof updateLogRequest>;
|
||||
export type UpdateLogResponse = z.infer<typeof updateLogResponse>;
|
||||
export type DeleteLogRequest = z.infer<typeof deleteLogRequest>;
|
||||
export type DeleteLogResponse = z.infer<typeof deleteLogResponse>;
|
||||
export type GetLogsRequest = z.infer<typeof getLogsRequest>;
|
||||
export type GetLogsResponse = z.infer<typeof getLogsResponse>;
|
||||
export type GetLogRequest = z.infer<typeof getLogRequest>;
|
||||
export type GetLogResponse = z.infer<typeof getLogResponse>;
|
||||
export type LogSummary = z.infer<typeof logSummary>;
|
||||
export type LogFailure = z.infer<typeof logFailure>;
|
||||
export type LogActiveTask = z.infer<typeof logActiveTask>;
|
||||
export type GetLogSummaryRequest = z.infer<typeof getLogSummaryRequest>;
|
||||
export type GetLogSummaryResponse = z.infer<typeof getLogSummaryResponse>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue