From 557df60c3b1672c896e4ed4b59823c39f3179b0f Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 19 May 2026 18:48:02 +0200 Subject: [PATCH] refactor: remove dead frontend API wrappers with no backend route (#24792) These 19 exported wrappers are dead: each appears exactly once in the codebase (its own definition), nothing imports or calls any of them, and none has a corresponding backend route. They are leftovers from settings that were consolidated server-side into /auths/admin/config, /openai/config, /ollama/config and /api/config: - index.ts: getModelFilterConfig, updateModelFilterConfig, getCommunitySharingEnabledStatus, toggleCommunitySharingEnabledStatus, getModelConfig, updateModelConfig (+ orphaned GlobalModelConfig type) - auths: getSignUpEnabledStatus, toggleSignUpEnabledStatus, getDefaultUserRole, updateDefaultUserRole, getJWTExpiresDuration, updateJWTExpiresDuration - openai: getOpenAIUrls, updateOpenAIUrls, getOpenAIKeys, updateOpenAIKeys - ollama: updateOllamaUrls - prompts: restorePromptFromHistory - folders: updateFolderItemsById (+ orphaned FolderItems type) Shared types (ModelConfig/ModelMeta/ModelParams) and all live wrappers are untouched. Removal is import-safe: nothing referenced these. Co-authored-by: Claude Opus 4.7 (1M context) --- src/lib/apis/auths/index.ts | 168 -------------------------------- src/lib/apis/folders/index.ts | 39 -------- src/lib/apis/index.ts | 175 ---------------------------------- src/lib/apis/ollama/index.ts | 35 ------- src/lib/apis/openai/index.ts | 134 -------------------------- src/lib/apis/prompts/index.ts | 39 -------- 6 files changed, 590 deletions(-) diff --git a/src/lib/apis/auths/index.ts b/src/lib/apis/auths/index.ts index 8f82f18b1b..5368c86064 100644 --- a/src/lib/apis/auths/index.ts +++ b/src/lib/apis/auths/index.ts @@ -470,174 +470,6 @@ export const updateUserPassword = async (token: string, password: string, newPas return res; }; -export const getSignUpEnabledStatus = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/signup/enabled`, { - method: 'GET', - 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.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const getDefaultUserRole = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/signup/user/role`, { - method: 'GET', - 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.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const updateDefaultUserRole = async (token: string, role: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/signup/user/role`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - role: role - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - error = err.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const toggleSignUpEnabledStatus = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/signup/enabled/toggle`, { - method: 'GET', - 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.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const getJWTExpiresDuration = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/token/expires`, { - method: 'GET', - 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.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const updateJWTExpiresDuration = async (token: string, duration: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/auths/token/expires/update`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - duration: duration - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - error = err.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - export const createAPIKey = async (token: string) => { let error = null; diff --git a/src/lib/apis/folders/index.ts b/src/lib/apis/folders/index.ts index af5405de3c..5ac37a8251 100644 --- a/src/lib/apis/folders/index.ts +++ b/src/lib/apis/folders/index.ts @@ -201,45 +201,6 @@ export const updateFolderParentIdById = async (token: string, id: string, parent return res; }; -type FolderItems = { - chat_ids: string[]; - file_ids: string[]; -}; - -export const updateFolderItemsById = async (token: string, id: string, items: FolderItems) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/folders/${id}/update/items`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - items: items - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .then((json) => { - return json; - }) - .catch((err) => { - error = err.detail; - console.error(err); - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - export const deleteFolderById = async (token: string, id: string, deleteContents: boolean) => { let error = null; diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index da07b87ea8..544434ab5d 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -1644,68 +1644,6 @@ export const getVersionUpdates = async (token: string) => { return res; }; -export const getModelFilterConfig = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/config/model/filter`, { - method: 'GET', - 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 const updateModelFilterConfig = async ( - token: string, - enabled: boolean, - models: string[] -) => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/config/model/filter`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - enabled: enabled, - models: models - }) - }) - .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 getWebhookUrl = async (token: string) => { let error = null; @@ -1763,87 +1701,6 @@ export const updateWebhookUrl = async (token: string, url: string) => { return res.url; }; -export const getCommunitySharingEnabledStatus = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/community_sharing`, { - method: 'GET', - 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 const toggleCommunitySharingEnabledStatus = async (token: string) => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/community_sharing/toggle`, { - method: 'GET', - 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.detail; - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - -export const getModelConfig = async (token: string): Promise => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/config/models`, { - method: 'GET', - 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.models; -}; - export interface ModelConfig { id: string; name: string; @@ -1860,35 +1717,3 @@ export interface ModelMeta { } export interface ModelParams {} - -export type GlobalModelConfig = ModelConfig[]; - -export const updateModelConfig = async (token: string, config: GlobalModelConfig) => { - let error = null; - - const res = await fetch(`${WEBUI_BASE_URL}/api/config/models`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - models: config - }) - }) - .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; -}; diff --git a/src/lib/apis/ollama/index.ts b/src/lib/apis/ollama/index.ts index a0f670d5e3..200945ce4d 100644 --- a/src/lib/apis/ollama/index.ts +++ b/src/lib/apis/ollama/index.ts @@ -135,41 +135,6 @@ export const getOllamaUrls = async (token: string = '') => { return res.OLLAMA_BASE_URLS; }; -export const updateOllamaUrls = async (token: string = '', urls: string[]) => { - let error = null; - - const res = await fetch(`${OLLAMA_API_BASE_URL}/urls/update`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - }, - body: JSON.stringify({ - urls: urls - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - if ('detail' in err) { - error = err.detail; - } else { - error = 'Server connection failed'; - } - return null; - }); - - if (error) { - throw error; - } - - return res.OLLAMA_BASE_URLS; -}; - export const getOllamaVersion = async (token: string, urlIdx?: number) => { let error = null; diff --git a/src/lib/apis/openai/index.ts b/src/lib/apis/openai/index.ts index 8cf7438ad3..d18565fec3 100644 --- a/src/lib/apis/openai/index.ts +++ b/src/lib/apis/openai/index.ts @@ -74,140 +74,6 @@ export const updateOpenAIConfig = async (token: string = '', config: OpenAIConfi return res; }; -export const getOpenAIUrls = async (token: string = '') => { - let error = null; - - const res = await fetch(`${OPENAI_API_BASE_URL}/urls`, { - method: 'GET', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - } - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - if ('detail' in err) { - error = err.detail; - } else { - error = 'Server connection failed'; - } - return null; - }); - - if (error) { - throw error; - } - - return res?.OPENAI_API_BASE_URLS ?? []; -}; - -export const updateOpenAIUrls = async (token: string = '', urls: string[]) => { - let error = null; - - const res = await fetch(`${OPENAI_API_BASE_URL}/urls/update`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - }, - body: JSON.stringify({ - urls: urls - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - if ('detail' in err) { - error = err.detail; - } else { - error = 'Server connection failed'; - } - return null; - }); - - if (error) { - throw error; - } - - return res.OPENAI_API_BASE_URLS; -}; - -export const getOpenAIKeys = async (token: string = '') => { - let error = null; - - const res = await fetch(`${OPENAI_API_BASE_URL}/keys`, { - method: 'GET', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - } - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - if ('detail' in err) { - error = err.detail; - } else { - error = 'Server connection failed'; - } - return null; - }); - - if (error) { - throw error; - } - - return res?.OPENAI_API_KEYS ?? []; -}; - -export const updateOpenAIKeys = async (token: string = '', keys: string[]) => { - let error = null; - - const res = await fetch(`${OPENAI_API_BASE_URL}/keys/update`, { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - ...(token && { authorization: `Bearer ${token}` }) - }, - body: JSON.stringify({ - keys: keys - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - if ('detail' in err) { - error = err.detail; - } else { - error = 'Server connection failed'; - } - return null; - }); - - if (error) { - throw error; - } - - return res.OPENAI_API_KEYS; -}; - export const getOpenAIModelsDirect = async (url: string, key: string) => { let error = null; diff --git a/src/lib/apis/prompts/index.ts b/src/lib/apis/prompts/index.ts index 5db7dc3540..bdcb1fef54 100644 --- a/src/lib/apis/prompts/index.ts +++ b/src/lib/apis/prompts/index.ts @@ -588,45 +588,6 @@ export const getPromptHistoryEntry = async ( return res; }; -export const restorePromptFromHistory = async ( - token: string, - promptId: string, - historyId: string, - commitMessage?: string -) => { - let error = null; - - const res = await fetch( - `${WEBUI_API_BASE_URL}/prompts/id/${promptId}/history/${historyId}/restore`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - commit_message: commitMessage - }) - } - ) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - error = err.detail; - console.error(err); - return null; - }); - - if (error) { - throw error; - } - - return res; -}; - export const getPromptDiff = async ( token: string, promptId: string,