Skip to content

Commit 02bb868

Browse files
fix(enrichment): require work email domain mapping
1 parent 510c528 commit 02bb868

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

apps/sim/enrichments/readiness.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ describe('getEnrichmentReadiness', () => {
1212
const readiness = getEnrichmentReadiness(workEmailEnrichment, { fullName: 'John Doe' })
1313

1414
expect(readiness.ready).toBe(false)
15-
expect(readiness.missingInputs.map((input) => input.id)).toEqual([
16-
'companyDomain',
17-
'linkedinUrl',
18-
])
15+
expect(readiness.missingInputs.map((input) => input.id)).toEqual(['companyDomain'])
1916
})
2017

2118
it('accepts either a name with company domain or a LinkedIn URL', () => {

apps/sim/enrichments/readiness.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@ export function getEnrichmentReadiness(
3535
return { ready: false, missingInputs: missingRequired }
3636
}
3737

38-
const providerSpecificInputs = enrichment.inputs.filter((input) => !input.required)
38+
const waitingInputs = enrichment.waitingInputIds?.map((inputId) => {
39+
const input = enrichment.inputs.find((candidate) => candidate.id === inputId)
40+
if (!input) {
41+
throw new Error(`Enrichment ${enrichment.id} has no waiting input ${inputId}`)
42+
}
43+
return input
44+
})
3945
return {
4046
ready: false,
41-
missingInputs: providerSpecificInputs.length > 0 ? providerSpecificInputs : enrichment.inputs,
47+
missingInputs: waitingInputs ?? enrichment.inputs,
4248
}
4349
}
4450

apps/sim/enrichments/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export interface EnrichmentConfig {
7777
/** Shown in the catalog + (future) column header. */
7878
icon: React.ComponentType<{ className?: string }>
7979
inputs: EnrichmentInputField[]
80+
/** Inputs named when no provider can build a request from the current row. */
81+
waitingInputIds?: string[]
8082
outputs: EnrichmentOutputField[]
8183
/** Data sources tried in order until one returns a non-empty result. */
8284
providers: EnrichmentProvider[]

apps/sim/enrichments/work-email/work-email.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const nameDomain = { fullName: 'John Doe', companyDomain: 'https://www.acme.com/
1515
const linkedinOnly = { fullName: 'John Doe', linkedinUrl: 'https://linkedin.com/in/johndoe' }
1616

1717
describe('work-email enrichment cascade', () => {
18+
it('requires full name and company domain mappings when saved', () => {
19+
expect(
20+
workEmailEnrichment.inputs.filter((input) => input.required).map((input) => input.id)
21+
).toEqual(['fullName', 'companyDomain'])
22+
})
23+
1824
it('chains the hosted providers in waterfall order', () => {
1925
expect(workEmailEnrichment.providers.map((p) => p.id)).toEqual([
2026
'hunter',

apps/sim/enrichments/work-email/work-email.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export const workEmailEnrichment: EnrichmentConfig = {
2020
icon: Mail,
2121
inputs: [
2222
{ id: 'fullName', name: 'Full name', type: 'string', required: true },
23-
{ id: 'companyDomain', name: 'Company domain', type: 'string' },
23+
{ id: 'companyDomain', name: 'Company domain', type: 'string', required: true },
2424
{ id: 'linkedinUrl', name: 'LinkedIn URL', type: 'string' },
2525
],
26+
waitingInputIds: ['companyDomain', 'linkedinUrl'],
2627
outputs: [{ id: 'email', name: 'email', type: 'string' }],
2728
providers: [
2829
toolProvider({

0 commit comments

Comments
 (0)