Skip to content

Commit 510c528

Browse files
fix(enrichment): separate save and row readiness
1 parent 27ac7bc commit 510c528

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

apps/sim/enrichments/readiness.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('getEnrichmentReadiness', () => {
1818
])
1919
})
2020

21-
it('accepts either a company domain or LinkedIn URL', () => {
21+
it('accepts either a name with company domain or a LinkedIn URL', () => {
2222
expect(
2323
getEnrichmentReadiness(workEmailEnrichment, {
2424
fullName: 'John Doe',
@@ -27,12 +27,20 @@ describe('getEnrichmentReadiness', () => {
2727
).toBe(true)
2828
expect(
2929
getEnrichmentReadiness(workEmailEnrichment, {
30-
fullName: 'John Doe',
3130
linkedinUrl: 'https://linkedin.com/in/johndoe',
3231
}).ready
3332
).toBe(true)
3433
})
3534

35+
it('does not treat a save-required mapping as a required value for every row', () => {
36+
const readiness = getEnrichmentReadiness(workEmailEnrichment, {
37+
fullName: '',
38+
linkedinUrl: 'https://linkedin.com/in/johndoe',
39+
})
40+
41+
expect(readiness).toEqual({ ready: true, missingInputs: [] })
42+
})
43+
3644
it('reports missing required inputs before provider-specific inputs', () => {
3745
const readiness = getEnrichmentReadiness(workEmailEnrichment, {
3846
companyDomain: 'acme.com',

apps/sim/enrichments/readiness.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export interface EnrichmentRowReadiness extends EnrichmentReadiness {
1818
inputColumnById: ReadonlyMap<string, string>
1919
}
2020

21-
/**
22-
* Checks whether an enrichment has its required inputs and at least one
23-
* provider can build a valid request from the available values.
24-
*/
21+
/** Checks whether at least one provider can build a valid request. */
2522
export function getEnrichmentReadiness(
2623
enrichment: EnrichmentConfig,
2724
inputs: Record<string, unknown>
2825
): EnrichmentReadiness {
26+
const ready = enrichment.providers.some((provider) => provider.buildParams(inputs) !== null)
27+
if (ready) return { ready: true, missingInputs: [] }
28+
2929
const isEmpty = (value: unknown) =>
3030
value === undefined || value === null || (typeof value === 'string' && value.trim() === '')
3131
const missingRequired = enrichment.inputs.filter(
@@ -35,9 +35,6 @@ export function getEnrichmentReadiness(
3535
return { ready: false, missingInputs: missingRequired }
3636
}
3737

38-
const ready = enrichment.providers.some((provider) => provider.buildParams(inputs) !== null)
39-
if (ready) return { ready: true, missingInputs: [] }
40-
4138
const providerSpecificInputs = enrichment.inputs.filter((input) => !input.required)
4239
return {
4340
ready: false,

apps/sim/enrichments/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface EnrichmentInputField {
99
/** Human label shown in the config panel. */
1010
name: string
1111
type: 'string' | 'number' | 'boolean'
12+
/** Whether a column mapping is required before the enrichment can be saved. */
1213
required?: boolean
1314
description?: string
1415
}

0 commit comments

Comments
 (0)