mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-05 21:04:43 +08:00
♻️ Fix handler cast specificity
This commit is contained in:
parent
47c4931b79
commit
04efee8b9b
@ -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: [] };
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user