MCPcopy
hub / github.com/triggerdotdev/trigger.dev / WebhookSource

Class WebhookSource

packages/trigger-sdk/src/triggers/webhook.ts:153–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151};
152
153export class WebhookSource<
154 TIntegration extends TriggerIntegration,
155 TParams extends any = any,
156 TConfig extends Record<string, string[]> = Record<string, string[]>,
157> {
158 constructor(private options: WebhookOptions<TIntegration, TParams, TConfig>) {}
159
160 async generateEvents(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext) {
161 return this.options.generateEvents({
162 request,
163 client,
164 ctx,
165 });
166 }
167
168 filter(params: TParams, config?: TConfig): EventFilter {
169 return this.options.filter?.(params, config) ?? {};
170 }
171
172 properties(params: TParams): DisplayProperty[] {
173 return this.options.properties?.(params) ?? [];
174 }
175
176 get crud() {
177 return this.options.crud;
178 }
179
180 async register(
181 params: TParams,
182 registerEvent: WebhookRegisterEvent<TConfig>,
183 io: IO,
184 ctx: TriggerContext
185 ) {
186 if (!this.options.register) {
187 return;
188 }
189
190 const updates = await this.options.register(
191 {
192 ...registerEvent,
193 params,
194 },
195 io as IOWithIntegrations<{ integration: TIntegration }>,
196 ctx
197 );
198
199 return updates;
200 }
201
202 async verify(
203 request: Request,
204 client: TriggerClient,
205 ctx: WebhookDeliveryContext
206 ): Promise<VerifyResult> {
207 if (this.options.verify) {
208 const clonedRequest = request.clone();
209 return this.options.verify({ request: clonedRequest, client, ctx });
210 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…