MCPcopy Index your code
hub / github.com/github/docs / getInitialPageWebhooks

Function getInitialPageWebhooks

src/webhooks/lib/index.js:17–51  ·  view source on GitHub ↗
(version)

Source from the content-addressed store, hash-verified

15// return the webhoook data as described for `initialWebhooksCache` for the given
16// version
17export async function getInitialPageWebhooks(version) {
18 if (initialWebhooksCache.has(version)) {
19 return initialWebhooksCache.get(version)
20 }
21 const allWebhooks = await getWebhooks(version)
22 const initialWebhooks = []
23
24 // The webhooks page shows all webhooks but for each webhook only a single
25 // webhook action type at a time. We pick the first webhook type from each
26 // webhook's set of action types to show.
27 for (const [key, webhook] of Object.entries(allWebhooks)) {
28 const actionTypes = Object.keys(webhook)
29 const defaultAction = actionTypes ? actionTypes[0] : null
30
31 const initialWebhook = {
32 name: key,
33 actionTypes,
34 data: webhook[defaultAction],
35 }
36
37 // remove all nested params for the initial webhooks page, we'll load
38 // them by request
39 if (initialWebhook.data.bodyParameters) {
40 initialWebhook.data.bodyParameters.forEach((bodyParam) => {
41 if (bodyParam.childParamsGroups) {
42 bodyParam.childParamsGroups = []
43 }
44 })
45 }
46
47 initialWebhooks.push({ ...initialWebhook })
48 }
49 initialWebhooksCache.set(version, initialWebhooks)
50 return initialWebhooks
51}
52
53// returns the webhook data for the given version and webhook category (e.g.
54// `check_run`) -- this includes all the data per webhook action type and all

Callers 1

getServerSidePropsFunction · 0.90

Calls 1

getWebhooksFunction · 0.70

Tested by

no test coverage detected