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

Function updateWebhookProviderConfig

apps/sim/lib/webhooks/polling/utils.ts:159–185  ·  view source on GitHub ↗
(
  webhookId: string,
  configUpdates: Record<string, unknown>,
  logger: Logger
)

Source from the content-addressed store, hash-verified

157 * the `json` column.
158 */
159export async function updateWebhookProviderConfig(
160 webhookId: string,
161 configUpdates: Record<string, unknown>,
162 logger: Logger
163): Promise<void> {
164 try {
165 const defined: Record<string, unknown> = {}
166 const removedKeys: string[] = []
167 for (const [key, value] of Object.entries(configUpdates)) {
168 if (value === undefined) removedKeys.push(key)
169 else defined[key] = value
170 }
171
172 const merged = sql`COALESCE(${webhook.providerConfig}::jsonb, '{}'::jsonb) || ${JSON.stringify(defined)}::jsonb`
173 const nextConfig = removedKeys.length > 0 ? sql`(${merged}) - ${removedKeys}::text[]` : merged
174
175 await db
176 .update(webhook)
177 .set({
178 providerConfig: sql`(${nextConfig})::json`,
179 updatedAt: new Date(),
180 })
181 .where(eq(webhook.id, webhookId))
182 } catch (err) {
183 logger.error(`Failed to update webhook ${webhookId} config:`, err)
184 }
185}
186
187/**
188 * Resolve OAuth credentials for a webhook. Shared by Gmail and Outlook.

Callers 10

pollWebhookFunction · 0.90
updateImapStateFunction · 0.90
updateRssStateFunction · 0.90
utils.test.tsFile · 0.90
pollSearchBasedFunction · 0.90
pollListMembershipFunction · 0.90
pollWebhookFunction · 0.90
pollWebhookFunction · 0.90
pollWebhookFunction · 0.90
pollWebhookFunction · 0.90

Calls 4

errorMethod · 0.80
setMethod · 0.65
eqFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected