({
webhook: webhookRecord,
workflow,
requestId,
strict,
}: DeleteSubscriptionContext)
| 569 | }, |
| 570 | |
| 571 | async deleteSubscription({ |
| 572 | webhook: webhookRecord, |
| 573 | workflow, |
| 574 | requestId, |
| 575 | strict, |
| 576 | }: DeleteSubscriptionContext): Promise<void> { |
| 577 | try { |
| 578 | const config = getProviderConfig(webhookRecord) |
| 579 | const { baseId, externalId } = config as { |
| 580 | baseId?: string |
| 581 | externalId?: string |
| 582 | } |
| 583 | |
| 584 | if (!baseId) { |
| 585 | logger.warn(`[${requestId}] Missing baseId for Airtable webhook deletion`, { |
| 586 | webhookId: webhookRecord.id, |
| 587 | }) |
| 588 | if (strict) throw new Error('Missing Airtable baseId for webhook deletion') |
| 589 | return |
| 590 | } |
| 591 | |
| 592 | const baseIdValidation = validateAirtableId(baseId, 'app', 'baseId') |
| 593 | if (!baseIdValidation.isValid) { |
| 594 | logger.warn(`[${requestId}] Invalid Airtable base ID format, skipping deletion`, { |
| 595 | webhookId: webhookRecord.id, |
| 596 | baseId: baseId.substring(0, 20), |
| 597 | }) |
| 598 | if (strict) throw new Error('Invalid Airtable baseId for webhook deletion') |
| 599 | return |
| 600 | } |
| 601 | |
| 602 | const credentialId = config.credentialId as string | undefined |
| 603 | if (!credentialId) { |
| 604 | logger.warn( |
| 605 | `[${requestId}] Missing credentialId for Airtable webhook deletion ${webhookRecord.id}` |
| 606 | ) |
| 607 | if (strict) throw new Error('Missing Airtable credentialId for webhook deletion') |
| 608 | return |
| 609 | } |
| 610 | |
| 611 | const credentialOwner = await getCredentialOwner(credentialId, requestId) |
| 612 | const accessToken = credentialOwner |
| 613 | ? await refreshAccessTokenIfNeeded( |
| 614 | credentialOwner.accountId, |
| 615 | credentialOwner.userId, |
| 616 | requestId |
| 617 | ) |
| 618 | : null |
| 619 | if (!accessToken) { |
| 620 | const message = `[${requestId}] Could not retrieve Airtable access token. Cannot delete webhook in Airtable.` |
| 621 | logger.warn(message, { webhookId: webhookRecord.id }) |
| 622 | if (strict) throw new Error(message) |
| 623 | return |
| 624 | } |
| 625 | |
| 626 | let resolvedExternalId: string | undefined = externalId |
| 627 | let externalIdLookupFailed = false |
| 628 |
nothing calls this directly
no test coverage detected