fix(open-webui): use current request-handler API to fix the build

The request handlers were written against an older caching API that dev has
since refactored ('TanStack Query as single source of truth'), breaking the
Turbopack build with a module-not-found on ./lib/cached-integration-request-handler.

- use createIntegrationRequestHandler from ./lib/integration-request-handler
- replace cacheDuration(dayjs)/queryKey with cacheTtlMs (ms)
- update the router consumers: getCachedOrUpdatedDataAsync -> getDataAsync and
  per-call invalidateAsync() -> handler-level invalidateCache()
This commit is contained in:
Thomas Camlong committed 2026-07-11 19:33:42 +02:00
1 parent 87f1f329da
commit 68ce7e73c0
2 files changed
+28 -36

No files matched your search

+11 -11
View File
@@ -170,7 +170,7 @@ export const openWebUiRouter = createTRPCRouter({
getModels: publicProcedure.concat(createOneIntegrationMiddleware("query", "openWebUi")).query(async ({ ctx }) => {
throwIfNotCreator(ctx.integration, ctx.session?.user.id);
const handler = openWebUiModelsRequestHandler.handler(ctx.integration, {});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -181,7 +181,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiChatsRequestHandler.handler(ctx.integration, {});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -193,7 +193,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiKnowledgeRequestHandler.handler(ctx.integration, {});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -202,7 +202,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiFilesRequestHandler.handler(ctx.integration, {});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -211,7 +211,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiNotesRequestHandler.handler(ctx.integration, {});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -221,7 +221,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx, input }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiNoteRequestHandler.handler(ctx.integration, { noteId: input.noteId });
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -233,7 +233,7 @@ export const openWebUiRouter = createTRPCRouter({
const handler = openWebUiKnowledgeFilesRequestHandler.handler(ctx.integration, {
knowledgeId: input.knowledgeId,
});
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -281,7 +281,7 @@ export const openWebUiRouter = createTRPCRouter({
.query(async ({ ctx, input }) => {
throwIfNotCreator(ctx.integration, ctx.session.user.id);
const handler = openWebUiChatRequestHandler.handler(ctx.integration, { chatId: input.chatId });
const { data } = await handler.getCachedOrUpdatedDataAsync({ forceUpdate: false });
const { data } = await handler.getDataAsync();
return data;
}),
@@ -297,7 +297,7 @@ export const openWebUiRouter = createTRPCRouter({
messages: input.messages,
meta: { tags: [homarrUserTag(ctx.session.user.id)] },
});
await openWebUiChatsRequestHandler.handler(ctx.integration, {}).invalidateAsync();
openWebUiChatsRequestHandler.invalidateCache();
return chat;
}),
@@ -311,8 +311,8 @@ export const openWebUiRouter = createTRPCRouter({
...input.chat,
meta: { tags: [homarrUserTag(ctx.session.user.id)] },
});
await openWebUiChatsRequestHandler.handler(ctx.integration, {}).invalidateAsync();
await openWebUiChatRequestHandler.handler(ctx.integration, { chatId: input.chatId }).invalidateAsync();
openWebUiChatsRequestHandler.invalidateCache();
openWebUiChatRequestHandler.invalidateCache();
return chat;
}),
+17 -25
View File
@@ -10,9 +10,9 @@ import type {
OpenWebUiNote,
} from "@homarr/integrations/types";
import { createCachedIntegrationRequestHandler } from "./lib/cached-integration-request-handler";
import { createIntegrationRequestHandler } from "./lib/integration-request-handler";
export const openWebUiModelsRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiModelsRequestHandler = createIntegrationRequestHandler<
OpenWebUiModel[],
"openWebUi",
Record<string, never>
@@ -21,11 +21,10 @@ export const openWebUiModelsRequestHandler = createCachedIntegrationRequestHandl
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.getModelsAsync();
},
cacheDuration: dayjs.duration(5, "minutes"),
queryKey: "openWebUiModels",
cacheTtlMs: dayjs.duration(5, "minutes").asMilliseconds(),
});
export const openWebUiKnowledgeRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiKnowledgeRequestHandler = createIntegrationRequestHandler<
OpenWebUiKnowledge[],
"openWebUi",
Record<string, never>
@@ -34,11 +33,10 @@ export const openWebUiKnowledgeRequestHandler = createCachedIntegrationRequestHa
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.getKnowledgeAsync();
},
cacheDuration: dayjs.duration(5, "minutes"),
queryKey: "openWebUiKnowledge",
cacheTtlMs: dayjs.duration(5, "minutes").asMilliseconds(),
});
export const openWebUiKnowledgeFilesRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiKnowledgeFilesRequestHandler = createIntegrationRequestHandler<
OpenWebUiFileSummary[],
"openWebUi",
{ knowledgeId: string }
@@ -47,11 +45,10 @@ export const openWebUiKnowledgeFilesRequestHandler = createCachedIntegrationRequ
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.getKnowledgeFilesAsync(input.knowledgeId);
},
cacheDuration: dayjs.duration(1, "minute"),
queryKey: "openWebUiKnowledgeFiles",
cacheTtlMs: dayjs.duration(1, "minute").asMilliseconds(),
});
export const openWebUiFilesRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiFilesRequestHandler = createIntegrationRequestHandler<
OpenWebUiFileSummary[],
"openWebUi",
Record<string, never>
@@ -60,11 +57,10 @@ export const openWebUiFilesRequestHandler = createCachedIntegrationRequestHandle
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.listFilesAsync();
},
cacheDuration: dayjs.duration(30, "seconds"),
queryKey: "openWebUiFiles",
cacheTtlMs: dayjs.duration(30, "seconds").asMilliseconds(),
});
export const openWebUiNotesRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiNotesRequestHandler = createIntegrationRequestHandler<
OpenWebUiNote[],
"openWebUi",
Record<string, never>
@@ -73,11 +69,10 @@ export const openWebUiNotesRequestHandler = createCachedIntegrationRequestHandle
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.listNotesAsync();
},
cacheDuration: dayjs.duration(30, "seconds"),
queryKey: "openWebUiNotes",
cacheTtlMs: dayjs.duration(30, "seconds").asMilliseconds(),
});
export const openWebUiNoteRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiNoteRequestHandler = createIntegrationRequestHandler<
OpenWebUiNote,
"openWebUi",
{ noteId: string }
@@ -86,11 +81,10 @@ export const openWebUiNoteRequestHandler = createCachedIntegrationRequestHandler
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.getNoteAsync(input.noteId);
},
cacheDuration: dayjs.duration(30, "seconds"),
queryKey: "openWebUiNote",
cacheTtlMs: dayjs.duration(30, "seconds").asMilliseconds(),
});
export const openWebUiChatsRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiChatsRequestHandler = createIntegrationRequestHandler<
OpenWebUiChatListItem[],
"openWebUi",
Record<string, never>
@@ -99,11 +93,10 @@ export const openWebUiChatsRequestHandler = createCachedIntegrationRequestHandle
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.listChatsAsync();
},
cacheDuration: dayjs.duration(15, "seconds"),
queryKey: "openWebUiChats",
cacheTtlMs: dayjs.duration(15, "seconds").asMilliseconds(),
});
export const openWebUiChatRequestHandler = createCachedIntegrationRequestHandler<
export const openWebUiChatRequestHandler = createIntegrationRequestHandler<
OpenWebUiChat,
"openWebUi",
{ chatId: string }
@@ -112,6 +105,5 @@ export const openWebUiChatRequestHandler = createCachedIntegrationRequestHandler
const integrationInstance = await createIntegrationAsync(integration);
return await integrationInstance.getChatAsync(input.chatId);
},
cacheDuration: dayjs.duration(15, "seconds"),
queryKey: "openWebUiChat",
cacheTtlMs: dayjs.duration(15, "seconds").asMilliseconds(),
});