♻️ Fix handler cast specificity

This commit is contained in:
Baptiste Arnaud 2025-12-04 14:33:55 +01:00
parent 47c4931b79
commit 04efee8b9b
No known key found for this signature in database
4 changed files with 8 additions and 8 deletions

View File

@ -94,9 +94,9 @@ export const fetchSelectItems = authenticatedProcedure
)
: undefined;
const handler = forgedBlockHandlers[input.integrationId].find(
const handler = forgedBlockHandlers[input.integrationId]?.find(
(handler) => handler.type === "fetcher" && handler.id === input.fetcherId,
) as FetcherHandler;
) as FetcherHandler | undefined;
if (!handler) return { items: [] };

View File

@ -126,9 +126,9 @@ export async function POST(req: Request) {
{ status: 400, headers: responseHeaders },
);
const handler = forgedBlockHandlers[block.type].find(
const handler = forgedBlockHandlers[block.type]?.find(
(h) => h.type === "action" && h.actionName === block.options?.action,
) as ActionHandler;
) as ActionHandler | undefined;
if (!handler || !handler.stream)
return NextResponse.json(

View File

@ -103,9 +103,9 @@ export const getMessageStream = async ({
message: "This block does not have a stream function",
};
const handler = forgedBlockHandlers[block.type].find(
const handler = forgedBlockHandlers[block.type]?.find(
(h) => h.type === "action" && h.actionName === block.options?.action,
) as ActionHandler;
) as ActionHandler | undefined;
if (!handler || !handler.stream)
return {

View File

@ -34,9 +34,9 @@ export const executeForgedBlock = async (
const blockDef = forgedBlocks[block.type];
if (!blockDef) return { outgoingEdgeId: block.outgoingEdgeId };
const action = blockDef.actions.find((a) => a.name === block.options?.action);
const handler = forgedBlockHandlers[block.type].find(
const handler = forgedBlockHandlers[block.type]?.find(
(h) => h.type === "action" && h.actionName === action?.name,
) as ActionHandler;
) as ActionHandler | undefined;
if (!block.options || !handler || !action)
return {
outgoingEdgeId: block.outgoingEdgeId,