mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-01 20:03:30 +02:00
Merge pull request #594 from CREDO23/feat/add-jotai-tanstack-connectors
[Feat] Connectors| Add jotai & tanstack
This commit is contained in:
commit
2c2ae40274
30 changed files with 3765 additions and 3322 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>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue