MCPcopy Index your code
hub / github.com/simstudioai/sim / deleteSubscription

Function deleteSubscription

apps/sim/lib/webhooks/providers/vercel.ts:210–250  ·  view source on GitHub ↗
(ctx: DeleteSubscriptionContext)

Source from the content-addressed store, hash-verified

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>

Callers

nothing calls this directly

Calls 4

getProviderConfigFunction · 0.90
cancelMethod · 0.80
infoMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected