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

Function syncCredentialSetWebhooks

apps/sim/lib/webhooks/deploy.ts:398–481  ·  view source on GitHub ↗
(params: {
  workflowId: string
  blockId: string
  provider: string
  triggerPath: string
  providerConfig: Record<string, unknown>
  requestId: string
  deploymentVersionId?: string
})

Source from the content-addressed store, hash-verified

396}
397
398async function syncCredentialSetWebhooks(params: {
399 workflowId: string
400 blockId: string
401 provider: string
402 triggerPath: string
403 providerConfig: Record<string, unknown>
404 requestId: string
405 deploymentVersionId?: string
406}): Promise<CredentialSetSyncResult> {
407 const {
408 workflowId,
409 blockId,
410 provider,
411 triggerPath,
412 providerConfig,
413 requestId,
414 deploymentVersionId,
415 } = params
416
417 const credentialSetId = providerConfig.credentialSetId as string | undefined
418 if (!credentialSetId) {
419 return { error: null, warnings: [] }
420 }
421
422 const oauthProviderId = getProviderIdFromServiceId(provider)
423
424 const { credentialId: _cId, credentialSetId: _csId, userId: _uId, ...baseConfig } = providerConfig
425
426 const syncResult = await syncWebhooksForCredentialSet({
427 workflowId,
428 blockId,
429 provider,
430 basePath: triggerPath,
431 credentialSetId,
432 oauthProviderId,
433 providerConfig: baseConfig as Record<string, unknown>,
434 requestId,
435 deploymentVersionId,
436 })
437
438 const warnings: string[] = []
439
440 if (syncResult.failed.length > 0) {
441 const failedCount = syncResult.failed.length
442 const totalCount = syncResult.webhooks.length + failedCount
443 warnings.push(
444 `${failedCount} of ${totalCount} credentials in the set failed to sync for ${provider}. Some team members may not receive triggers.`
445 )
446 }
447
448 if (syncResult.webhooks.length === 0) {
449 return {
450 error: {
451 message: `No valid credentials found in credential set for ${provider}. Please connect accounts and try again.`,
452 status: 400,
453 },
454 warnings,
455 }

Callers 1

Calls 7

getProviderHandlerFunction · 0.90
configurePollingMethod · 0.80
deleteMethod · 0.65
eqFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected