PlatformWebhooks.utils.ts49 lines · main
1import type { WebhookEndpoint } from './PlatformWebhooks.types'
2
3const WEBHOOK_NAME_ADJECTIVES = [
4 'swift',
5 'winged',
6 'wayfinding',
7 'moonlit',
8 'fleet',
9 'nimble',
10 'roving',
11 'brisk',
12 'gliding',
13 'steady',
14 'northbound',
15 'starlit',
16 'quiet',
17 'amber',
18 'far-flung',
19 'secret',
20 'flying',
21]
22
23const WEBHOOK_NAME_NOUNS = [
24 'pigeon',
25 'courier',
26 'postmark',
27 'relay',
28 'dispatch',
29 'lantern',
30 'beacon',
31 'messenger',
32 'waypost',
33 'sparrow',
34 'satchel',
35 'signalfire',
36 'envelope',
37 'parcel',
38 'gull',
39 'kite',
40 'beagle',
41]
42
43const getRandomItem = (values: string[]) => values[Math.floor(Math.random() * values.length)]
44
45export const generateWebhookEndpointName = () =>
46 `${getRandomItem(WEBHOOK_NAME_ADJECTIVES)}-${getRandomItem(WEBHOOK_NAME_NOUNS)}`
47
48export const getWebhookEndpointDisplayName = (endpoint: Pick<WebhookEndpoint, 'name' | 'url'>) =>
49 endpoint.name.trim() || endpoint.url