(ctx: DeleteSubscriptionContext)
| 208 | }, |
| 209 | |
| 210 | async deleteSubscription(ctx: DeleteSubscriptionContext): Promise<void> { |
| 211 | const { webhook, requestId } = ctx |
| 212 | try { |
| 213 | const config = getProviderConfig(webhook) |
| 214 | const apiKey = config.apiKey as string | undefined |
| 215 | const externalId = config.externalId as string | undefined |
| 216 | const teamId = config.teamId as string | undefined |
| 217 | |
| 218 | if (!apiKey || !externalId) { |
| 219 | logger.warn( |
| 220 | `[${requestId}] Missing apiKey or externalId for Vercel webhook deletion ${webhook.id}, skipping cleanup` |
| 221 | ) |
| 222 | if (ctx.strict) throw new Error('Missing Vercel webhook deletion credentials') |
| 223 | return |
| 224 | } |
| 225 | |
| 226 | const apiUrl = teamId |
| 227 | ? `https://api.vercel.com/v1/webhooks/${encodeURIComponent(externalId)}?teamId=${encodeURIComponent(teamId)}` |
| 228 | : `https://api.vercel.com/v1/webhooks/${encodeURIComponent(externalId)}` |
| 229 | |
| 230 | const response = await fetch(apiUrl, { |
| 231 | method: 'DELETE', |
| 232 | headers: { |
| 233 | Authorization: `Bearer ${apiKey}`, |
| 234 | }, |
| 235 | }) |
| 236 | |
| 237 | if (!response.ok && response.status !== 404) { |
| 238 | logger.warn( |
| 239 | `[${requestId}] Failed to delete Vercel webhook (non-fatal): ${response.status}` |
| 240 | ) |
| 241 | if (ctx.strict) throw new Error(`Failed to delete Vercel webhook: ${response.status}`) |
| 242 | } else { |
| 243 | await response.body?.cancel() |
| 244 | logger.info(`[${requestId}] Successfully deleted Vercel webhook ${externalId}`) |
| 245 | } |
| 246 | } catch (error) { |
| 247 | logger.warn(`[${requestId}] Error deleting Vercel webhook (non-fatal)`, error) |
| 248 | if (ctx.strict) throw error |
| 249 | } |
| 250 | }, |
| 251 | |
| 252 | async formatInput(ctx: FormatInputContext): Promise<FormatInputResult> { |
| 253 | const body = ctx.body as Record<string, unknown> |
nothing calls this directly
no test coverage detected