This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-25 14:19:30 +01:00
1 parent 47a1bfdd15
commit 7453968678
5 files changed
+812 -59

No files matched your search

+108 -11
View File
@@ -1572,10 +1572,20 @@ export const getVersionUpdates = async (token: string) => {
return res;
};
export const getWebhookUrl = async (token: string) => {
export type EventWebhook = {
id: string;
name: string;
url: string;
enabled: boolean;
events: string[];
created_at?: number;
updated_at?: number;
};
export const getEvents = async (token: string) => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/webhook`, {
const res = await fetch(`${WEBUI_BASE_URL}/api/events`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
@@ -1596,21 +1606,18 @@ export const getWebhookUrl = async (token: string) => {
throw error;
}
return res.url;
return res;
};
export const updateWebhookUrl = async (token: string, url: string) => {
export const getEventWebhooks = async (token: string): Promise<EventWebhook[]> => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/webhook`, {
method: 'POST',
const res = await fetch(`${WEBUI_BASE_URL}/api/events/webhooks`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
url: url
})
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
@@ -1626,7 +1633,97 @@ export const updateWebhookUrl = async (token: string, url: string) => {
throw error;
}
return res.url;
return res;
};
export const createEventWebhook = async (
token: string,
webhook: Partial<EventWebhook>
): Promise<EventWebhook> => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/events/webhooks`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify(webhook)
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err;
return null;
});
if (error) {
throw error;
}
return res;
};
export const updateEventWebhook = async (
token: string,
id: string,
webhook: Partial<EventWebhook>
): Promise<EventWebhook> => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/events/webhooks/${id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify(webhook)
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err;
return null;
});
if (error) {
throw error;
}
return res;
};
export const deleteEventWebhook = async (token: string, id: string) => {
let error = null;
const res = await fetch(`${WEBUI_BASE_URL}/api/events/webhooks/${id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.error(err);
error = err;
return null;
});
if (error) {
throw error;
}
return res;
};
export interface ModelConfig {