( workflowId: string, blockId: string, signal?: AbortSignal )
| 18 | export type { WebhookData } |
| 19 | |
| 20 | async function fetchWebhooks( |
| 21 | workflowId: string, |
| 22 | blockId: string, |
| 23 | signal?: AbortSignal |
| 24 | ): Promise<WebhookData | null> { |
| 25 | let data: ListWebhooksByBlockResponse |
| 26 | try { |
| 27 | data = await requestJson(listWebhooksByBlockContract, { |
| 28 | query: { workflowId, blockId }, |
| 29 | signal, |
| 30 | }) |
| 31 | } catch (error) { |
| 32 | if (isApiClientError(error) && error.status === 404) return null |
| 33 | throw error |
| 34 | } |
| 35 | |
| 36 | if (data.webhooks && data.webhooks.length > 0) { |
| 37 | return data.webhooks[0].webhook |
| 38 | } |
| 39 | |
| 40 | return null |
| 41 | } |
| 42 | |
| 43 | export function useWebhookQuery(workflowId: string, blockId: string, enabled = true) { |
| 44 | return useQuery({ |
no test coverage detected