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

Function createWebhookSource

integrations/airtable/src/webhooks.ts:267–385  ·  view source on GitHub ↗
(
  integration: Airtable
)

Source from the content-addressed store, hash-verified

265};
266
267export function createWebhookSource(
268 integration: Airtable
269): WebhookSource<
270 Airtable,
271 { baseId: string; tableId?: string },
272 { dataTypes: WebhookDataType[]; fromSources?: WebhookFromSource[] }
273> {
274 return new WebhookSource({
275 id: "airtable.webhook",
276 schemas: {
277 params: z.object({ baseId: z.string(), tableId: z.string().optional() }),
278 config: z.object({
279 dataTypes: z.array(WebhookDataTypeSchema),
280 fromSources: z.array(WebhookFromSourceSchema).optional(),
281 }),
282 },
283 version: "0.1.0",
284 integration,
285 filter: (params, options) => ({
286 actionMetadata: {
287 source: options?.fromSources ?? ["client", "anonymousUser", "formSubmission"],
288 },
289 }),
290 key: (params) =>
291 `airtable.webhook.${params.baseId}${params.tableId ? `.${params.tableId}` : ""}`,
292 crud: {
293 create: async ({ io, ctx }) => {
294 const webhook = await io.integration.webhooks().create("create-webhook", {
295 url: ctx.url,
296 baseId: ctx.params?.baseId,
297 options: getSpecification(ctx.config.desired, ctx.params),
298 });
299
300 await io.store.job.set("set-id", "webhook-id", webhook.id);
301 await io.store.job.set("set-secret", "webhook-secret-base64", webhook.macSecretBase64);
302 },
303 read: async ({ io, ctx }) => {
304 const listResponse = await io.integration.webhooks().list("list-webhooks", {
305 baseId: ctx.params?.baseId,
306 });
307
308 const existingWebhook = listResponse.webhooks.find((w) => w.notificationUrl === ctx.url);
309
310 if (!existingWebhook) {
311 return await io.store.job.delete("delete-stale-webhook-id", "webhook-id");
312 }
313
314 await io.store.job.set("set-webhook-id", "webhook-id", existingWebhook.id);
315 },
316 delete: async ({ io, ctx }) => {
317 const webhookId = await io.store.job.get<string>("get-webhook-id", "webhook-id");
318
319 if (!webhookId) {
320 throw new Error("Missing webhook ID for delete operation.");
321 }
322
323 await io.integration.webhooks().delete("delete-webhook", {
324 baseId: ctx.params?.baseId,

Callers 1

sourceMethod · 0.90

Calls 15

registerJobNamespaceFunction · 0.90
verifyRequestSignatureFunction · 0.90
getSpecificationFunction · 0.85
getAllPayloadsFunction · 0.85
findMethod · 0.80
parseMethod · 0.80
jsonMethod · 0.80
createMethod · 0.65
deleteMethod · 0.65
logMethod · 0.65
webhooksMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…