| 178 | }; |
| 179 | |
| 180 | export class WebhookEventCatalog< |
| 181 | TEvents extends Record<string, EventSpecification<any, any>>, |
| 182 | TSource extends WebhookSource<any>, |
| 183 | > { |
| 184 | constructor(private options: WebhookCatalogOptions<TEvents, TSource>) {} |
| 185 | |
| 186 | get events() { |
| 187 | return this.options.events; |
| 188 | } |
| 189 | |
| 190 | get source() { |
| 191 | return this.options.source; |
| 192 | } |
| 193 | |
| 194 | on<TName extends keyof TEvents, TParams extends GetWebhookParams<TSource>>( |
| 195 | name: TName, |
| 196 | params: TParams |
| 197 | ): WebhookTrigger<TEvents[TName], TSource> { |
| 198 | return new WebhookTrigger({ |
| 199 | event: this.events[name], |
| 200 | params, |
| 201 | source: this.source, |
| 202 | config: {}, |
| 203 | }); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | export function createWebhookEventCatalog(source: ReturnType<typeof createWebhookEventSource>) { |
| 208 | return new WebhookEventCatalog({ |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…