( subscription: SimSubscription, payload: SimEventPayload )
| 43 | * module stays cheap for the execution logger to import. |
| 44 | */ |
| 45 | export async function dispatchSimEvent( |
| 46 | subscription: SimSubscription, |
| 47 | payload: SimEventPayload |
| 48 | ): Promise<void> { |
| 49 | const requestId = generateShortId() |
| 50 | try { |
| 51 | const { processPolledWebhookEvent } = await import('@/lib/webhooks/processor') |
| 52 | const result = await processPolledWebhookEvent( |
| 53 | subscription.webhook, |
| 54 | subscription.workflow, |
| 55 | payload, |
| 56 | requestId |
| 57 | ) |
| 58 | |
| 59 | if (!result.success) { |
| 60 | logger.error( |
| 61 | `[${requestId}] Failed to fire sim trigger for workflow ${subscription.workflow.id}:`, |
| 62 | result.statusCode, |
| 63 | result.error |
| 64 | ) |
| 65 | } |
| 66 | } catch (error) { |
| 67 | logger.error( |
| 68 | `[${requestId}] Error firing sim trigger for workflow ${subscription.workflow.id}:`, |
| 69 | error |
| 70 | ) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /** Workflow-scope filter shared by all event kinds. Empty selection watches every workflow. */ |
| 75 | function matchesWorkflowScope(config: SimSubscriptionConfig, sourceWorkflowId: string): boolean { |
no test coverage detected