| 1 | import { MAX_WEBHOOK_DELIVERY_AGE_MINUTES } from "@t3tools/contracts"; |
| 2 | |
| 3 | /** Prompt a new webhook task starts with: just the body, so request headers stay out unless the user adds them. */ |
| 4 | export const DEFAULT_WEBHOOK_PROMPT = "Handle this webhook:\n{{body}}"; |
| 5 | |
| 6 | /** Blank means "no limit"; undefined means the input is not a valid limit, which blocks saving. */ |
| 7 | export function parseMaxDeliveryAge(value: string): number | null | undefined { |
| 8 | if (value.trim() === "") return null; |
| 9 | const minutes = Number(value.trim()); |
| 10 | return Number.isInteger(minutes) && minutes > 0 && minutes <= MAX_WEBHOOK_DELIVERY_AGE_MINUTES |
| 11 | ? minutes |
| 12 | : undefined; |
| 13 | } |