import type { WebhookEventSource } from '@admin/types/webhooks' import { toSentenceFragment } from '@admin/utils/text/to-sentence-fragment' export function describeWebhookEvent(event: string, source: WebhookEventSource): string { const action = event.slice(event.lastIndexOf('.') + 1) const noun = source.labelSingular ?? toSentenceFragment(source.label) switch (action) { case 'created': return `A ${noun} is created` case 'updated': return 'Fields change' case 'deleted': return 'Moved to trash' case 'published': return 'Draft goes live' case 'unpublished': return 'Back to draft' case 'restored': return 'A version is restored' case 'reordered': return 'Sort order changes' case 'submitted': return 'A submission arrives' default: return '' } }