Skip to content

feat: add Clearbit integration (person/company enrichment + autocomplete)#73

Open
jackulau wants to merge 1 commit into
wespreadjam:mainfrom
jackulau:15-clearbit-enrichment
Open

feat: add Clearbit integration (person/company enrichment + autocomplete)#73
jackulau wants to merge 1 commit into
wespreadjam:mainfrom
jackulau:15-clearbit-enrichment

Conversation

@jackulau

Copy link
Copy Markdown

Summary

Adds a Clearbit API integration covering the three operations specified in issue #15: person enrichment, company enrichment, and company autocomplete. Resolves #15.

Operations

Node Endpoint Purpose
clearbitEnrichPerson GET https://person-stream.clearbit.com/v2/people/find Enrich a person by email (optional: given/family name, company, company domain, linkedIn, twitter)
clearbitEnrichCompany GET https://company-stream.clearbit.com/v2/companies/find Enrich a company by domain
clearbitCompanyAutocomplete GET https://autocomplete.clearbit.com/v1/companies/suggest Suggest companies from a partial name

Credential

Single API-key credential (clearbit) authenticating via Authorization: Bearer {{apiKey}} header, defined through defineApiKeyCredential from @jam-nodes/core. Matches the shape declared in issue #15 exactly.

Implementation notes

  • Streaming endpoints. Uses Clearbit's person-stream / company-stream subdomains instead of the non-streaming alternatives, because the non-streaming endpoints return 202 + webhook callback (unsuitable for synchronous workflow execution). Matches the n8n reference implementation.
  • CamelCase → snake_case URL mapping. Input fields (givenName, familyName, companyDomain) are mapped to Clearbit's snake_case query params (given_name, family_name, company_domain). The linkedIn field specifically maps to lowercase linkedin to match Clearbit's URL convention.
  • Autocomplete namequery. The issue's input field is name but Clearbit's URL param is query; mapped at request-build time.
  • Response mapping. Clearbit returns richer objects than issue [Integration] Clearbit - Person and company enrichment #15 asks for; output schemas extract only the fields the issue specifies. Nullable fields (location, employment.title, social.github, etc.) are handled with ?? null and tested explicitly against sparse responses.
  • File per operation. clearbit-enrich-person.ts, clearbit-enrich-company.ts, clearbit-company-autocomplete.ts, each self-contained — follows the apify / devto precedent.
  • HTTP layer. Uses the shared fetchWithRetry utility (default: 3 retries, 1s initial backoff, 30s timeout). No retry/cache/timeout configuration inside node bodies — nodes stay pure per the architectural rule in CLAUDE.md.
  • Error handling. All three nodes return { success: false, error } on missing credentials, non-OK responses, malformed responses (missing id), and network failures. They never throw.

Files changed

  • packages/core/src/types/node.ts — extend NodeCredentials with clearbit?: { apiKey: string }
  • packages/nodes/src/integrations/clearbit/credentials.ts — new, clearbitCredential
  • packages/nodes/src/integrations/clearbit/schemas.ts — new, 6 Zod schemas + 6 inferred types
  • packages/nodes/src/integrations/clearbit/clearbit-enrich-person.ts — new node
  • packages/nodes/src/integrations/clearbit/clearbit-enrich-company.ts — new node
  • packages/nodes/src/integrations/clearbit/clearbit-company-autocomplete.ts — new node
  • packages/nodes/src/integrations/clearbit/index.ts — new barrel
  • packages/nodes/src/integrations/clearbit/__tests__/clearbit.test.ts — new, 50 tests
  • packages/nodes/src/integrations/index.ts — re-export clearbit
  • packages/nodes/src/index.ts — add value + type exports, append to builtInNodes[]

Test coverage (50 tests, all passing)

  • Credential (5): name/type/displayName, header Bearer authentication, documentation URL, schema accepts {apiKey}, schema rejects {}
  • Schemas (10): required-field validation + empty-string rejection + optional-field acceptance for all 3 operations
  • clearbit_enrich_person (13): missing API key, full happy path, endpoint URL, Bearer header, email query param, camelCase→snake_case mapping, linkedInlinkedin lowercase, omitting absent optionals, nullable response fields, missing nested social objects, 401, 404, missing-id guard, network failure
  • clearbit_enrich_company (11): missing API key, happy path, endpoint URL, Bearer header, category mapping, metrics mapping with nulls, absent social platforms, 401, 404, missing-id guard, network failure
  • clearbit_company_autocomplete (8): missing API key, happy path, endpoint URL, namequery param mapping, Bearer header, empty results, non-OK response, malformed (non-array) response, network failure
  • Integration (1): all 3 nodes return structured context.credentials.clearbit.apiKey error when credentials are absent

Verification

$ npm --workspace=@jam-nodes/nodes test
Test Files  10 passed (10)
     Tests  245 passed (245)
  Duration  10.72s
  • Full suite: 245/245 passing, zero regressions vs main baseline
  • Clearbit test file alone: 50/50 passing
  • tsc --noEmit scoped to clearbit files, integrations/index.ts, nodes/src/index.ts, types/node.ts: zero errors (pre-existing unrelated typecheck errors in apify/, google-sheets/, slack/ are untouched)

Acceptance criteria (from issue #15)

  • Credential definition
  • All 3 operations
  • Zod schemas
  • Unit tests

Closes #15

…ocomplete

Adds Clearbit API integration with 3 operations:
- clearbitEnrichPerson: enrich a person by email
- clearbitEnrichCompany: enrich a company by domain
- clearbitCompanyAutocomplete: suggest companies from a name

Uses Clearbit's synchronous streaming endpoints (person-stream, company-stream)
so nodes return results in a single call. Autocomplete uses the v1 suggest endpoint.

Credential: clearbit (apiKey type, Bearer header auth).
Wired into NodeCredentials, builtInNodes[], and the integrations barrel.

Covered by 50 unit + integration tests (all passing).

Resolves wespreadjam#15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Integration] Clearbit - Person and company enrichment

1 participant