Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2e89fe5
fix(triggers): apply webhook audit follow-ups
waleedlatif1 Apr 6, 2026
bb716bb
fix(webhooks): Salesforce provider handler, Zoom CRC and block wiring
waleedlatif1 Apr 6, 2026
0ddc769
fix(webhooks): harden Resend and Linear triggers (idempotency, auth, …
waleedlatif1 Apr 6, 2026
e9618d9
fix(webhooks): harden Vercel and Greenhouse trigger handlers
waleedlatif1 Apr 6, 2026
317d4ab
fix(gong): JWT verification, trigger UX, alignment script
waleedlatif1 Apr 6, 2026
729667a
fix(notion): align webhook lifecycle and outputs
waleedlatif1 Apr 6, 2026
e79c556
fix(webhooks): tighten remaining provider hardening
waleedlatif1 Apr 7, 2026
23ccc9b
refactor(webhooks): move subscription helpers out of providers
waleedlatif1 Apr 7, 2026
e000c5b
fix(zoom): resolve env-backed secrets during validation
waleedlatif1 Apr 7, 2026
b50a902
fix build
waleedlatif1 Apr 7, 2026
732755a
consolidate tests
waleedlatif1 Apr 7, 2026
7c31044
refactor(salesforce): share payload object type parsing
waleedlatif1 Apr 7, 2026
41b0348
fix(webhooks): address remaining review follow-ups
waleedlatif1 Apr 7, 2026
cae9c8b
test(webhooks): separate Zoom coverage and clean Notion output shape
waleedlatif1 Apr 7, 2026
a305fc2
feat(triggers): enrich Vercel and Greenhouse webhook output shapes
waleedlatif1 Apr 7, 2026
3e29341
feat(webhooks): enrich Resend trigger outputs; clarify Notion output …
waleedlatif1 Apr 7, 2026
5148936
feat(webhooks): enrich Zoom and Gong trigger output schemas
waleedlatif1 Apr 7, 2026
0600c90
feat(triggers): enrich Salesforce and Linear webhook output schemas
waleedlatif1 Apr 7, 2026
1cd27d8
remove from mdx
waleedlatif1 Apr 7, 2026
e0580f7
chore(webhooks): expand trigger alignment coverage
waleedlatif1 Apr 7, 2026
3e7a046
updated skills
waleedlatif1 Apr 7, 2026
d3fcf04
updated file naming semantics
waleedlatif1 Apr 7, 2026
2897ce1
rename file
waleedlatif1 Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(salesforce): share payload object type parsing
Remove dead code in the Salesforce provider and move shared object-type extraction into a single helper so trigger matching and input shaping stay in sync.

Made-with: Cursor
  • Loading branch information
waleedlatif1 committed Apr 7, 2026
commit 7c31044f6a9be2f26074ec8ea7c7f47e21cfdb82
36 changes: 2 additions & 34 deletions apps/sim/lib/webhooks/providers/salesforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
WebhookProviderHandler,
} from '@/lib/webhooks/providers/types'
import { verifyTokenAuth } from '@/lib/webhooks/providers/utils'
import { extractSalesforceObjectTypeFromPayload } from '@/lib/webhooks/salesforce-payload-utils'

const logger = createLogger('WebhookProvider:Salesforce')

Expand All @@ -25,39 +26,6 @@ function asRecord(body: unknown): Record<string, unknown> {
: {}
}

function extractObjectTypeFromPayload(body: Record<string, unknown>): string | undefined {
const direct =
(typeof body.objectType === 'string' && body.objectType) ||
(typeof body.sobjectType === 'string' && body.sobjectType) ||
undefined
if (direct) {
return direct
}

const attrs = body.attributes as Record<string, unknown> | undefined
if (typeof attrs?.type === 'string') {
return attrs.type
}

const record = body.record
if (record && typeof record === 'object' && !Array.isArray(record)) {
const r = record as Record<string, unknown>
if (typeof r.sobjectType === 'string') {
return r.sobjectType
}
const ra = r.attributes as Record<string, unknown> | undefined
if (typeof ra?.type === 'string') {
return ra.type
}
}

return undefined
}

function normalizeSObjectType(t: string): string {
return t.trim().toLowerCase()
}

function extractRecordCore(body: Record<string, unknown>): Record<string, unknown> {
const nested = body.record
if (nested && typeof nested === 'object' && !Array.isArray(nested)) {
Expand Down Expand Up @@ -176,7 +144,7 @@ export const salesforceHandler: WebhookProviderHandler = {

const record = extractRecordCore(body)
const objectType =
extractObjectTypeFromPayload(body) ||
extractSalesforceObjectTypeFromPayload(body) ||
(typeof record.attributes === 'object' &&
record.attributes &&
typeof (record.attributes as Record<string, unknown>).type === 'string'
Expand Down
30 changes: 30 additions & 0 deletions apps/sim/lib/webhooks/salesforce-payload-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export function extractSalesforceObjectTypeFromPayload(
body: Record<string, unknown>
): string | undefined {
const direct =
(typeof body.objectType === 'string' && body.objectType) ||
(typeof body.sobjectType === 'string' && body.sobjectType) ||
undefined
if (direct) {
return direct
}

const attrs = body.attributes as Record<string, unknown> | undefined
if (typeof attrs?.type === 'string') {
return attrs.type
}

const record = body.record
if (record && typeof record === 'object' && !Array.isArray(record)) {
const r = record as Record<string, unknown>
if (typeof r.sobjectType === 'string') {
return r.sobjectType
}
const ra = r.attributes as Record<string, unknown> | undefined
if (typeof ra?.type === 'string') {
return ra.type
}
}

return undefined
}
31 changes: 3 additions & 28 deletions apps/sim/triggers/salesforce/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { extractSalesforceObjectTypeFromPayload } from '@/lib/webhooks/salesforce-payload-utils'
import type { SubBlockConfig } from '@/blocks/types'
import type { TriggerOutput } from '@/triggers/types'

Expand All @@ -20,32 +21,6 @@ function normalizeToken(s: string): string {
.replace(/[\s-]+/g, '_')
}

function payloadObjectType(body: Record<string, unknown>): string | undefined {
const direct =
(typeof body.objectType === 'string' && body.objectType) ||
(typeof body.sobjectType === 'string' && body.sobjectType) ||
undefined
if (direct) {
return direct
}
const attrs = body.attributes as Record<string, unknown> | undefined
if (typeof attrs?.type === 'string') {
return attrs.type
}
const record = body.record
if (record && typeof record === 'object' && !Array.isArray(record)) {
const r = record as Record<string, unknown>
if (typeof r.sobjectType === 'string') {
return r.sobjectType
}
const ra = r.attributes as Record<string, unknown> | undefined
if (typeof ra?.type === 'string') {
return ra.type
}
}
return undefined
}

const RECORD_CREATED = new Set([
'record_created',
'created',
Expand Down Expand Up @@ -115,15 +90,15 @@ export function isSalesforceEventMatch(
if (!want) {
return true
}
const got = payloadObjectType(body)
const got = extractSalesforceObjectTypeFromPayload(body)
if (!got) {
return false
}
return normalizeToken(got) === normalizeToken(want)
}

const wantType = configuredObjectType?.trim()
const gotType = payloadObjectType(body)
const gotType = extractSalesforceObjectTypeFromPayload(body)
if (wantType) {
if (!gotType) {
return false
Expand Down
Loading