format with biome

This commit is contained in:
thierryverse 2025-11-14 00:42:19 +02:00
parent 77d49ca11c
commit 81ee04c2a5
21 changed files with 1602 additions and 1752 deletions

View file

@ -1,113 +1,107 @@
import { Connector, CreateConnectorRequest } from "@/hooks/use-connectors";
export const createConnector = async (
data: CreateConnectorRequest,
authToken: string
data: CreateConnectorRequest,
authToken: string
): Promise<Connector> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
body: JSON.stringify(data),
}
);
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
body: JSON.stringify(data),
}
);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to create connector");
}
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to create connector");
}
return response.json();
return response.json();
};
export const getConnectors = async (
skip = 0,
limit = 100,
authToken: string
skip = 0,
limit = 100,
authToken: string
): Promise<Connector[]> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors?skip=${skip}&limit=${limit}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors?skip=${skip}&limit=${limit}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to fetch connectors");
}
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to fetch connectors");
}
return response.json();
return response.json();
};
export const getConnector = async (
connectorId: number,
authToken: string
): Promise<Connector> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
export const getConnector = async (connectorId: number, authToken: string): Promise<Connector> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to fetch connector");
}
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to fetch connector");
}
return response.json();
return response.json();
};
export const updateConnector = async (
connectorId: number,
data: CreateConnectorRequest,
authToken: string
connectorId: number,
data: CreateConnectorRequest,
authToken: string
): Promise<Connector> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
body: JSON.stringify(data),
}
);
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authToken}`,
},
body: JSON.stringify(data),
}
);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to update connector");
}
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to update connector");
}
return response.json();
return response.json();
};
export const deleteConnector = async (
connectorId: number,
authToken: string
): Promise<void> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
export const deleteConnector = async (connectorId: number, authToken: string): Promise<void> => {
const response = await fetch(
`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/api/v1/search-source-connectors/${connectorId}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to delete connector");
}
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.detail || "Failed to delete connector");
}
};