(
eventId: string,
updates: {
processed: boolean;
processed_at: string;
handlers_triggered: string[];
errors: Array<{ message: string; handler: string; stack?: string }> | null;
}
)
| 54 | |
| 55 | /** |
| 56 | * Claims a delivery signature for `event`. Returns false when another delivery |
| 57 | * already holds it. A concurrent claim of the same signature waits for this |
| 58 | * transaction, so if the event insert that follows fails and the transaction |
| 59 | * rolls back, the delivery can be claimed again on retry. |
| 60 | */ |
| 61 | export async function claimWebhookEventSignature( |
| 62 | tx: DrizzleTransaction, |
| 63 | eventSignature: string, |
| 64 | event: WebhookEventRef |
| 65 | ): Promise<boolean> { |
| 66 | const claimed = await tx |
| 67 | .insert(webhook_event_signatures) |
| 68 | .values({ |
| 69 | event_signature: eventSignature, |
| 70 | webhook_event_id: event.id, |
| 71 | webhook_event_created_at: event.createdAt, |
| 72 | }) |
| 73 | .onConflictDoNothing({ target: webhook_event_signatures.event_signature }) |
| 74 | .returning({ eventSignature: webhook_event_signatures.event_signature }); |
| 75 | return claimed.length > 0; |
| 76 | } |
| 77 |
no test coverage detected