feat: add Clearbit integration (person/company enrichment + autocomplete)#73
Open
jackulau wants to merge 1 commit into
Open
feat: add Clearbit integration (person/company enrichment + autocomplete)#73jackulau wants to merge 1 commit into
jackulau wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Clearbit API integration covering the three operations specified in issue #15: person enrichment, company enrichment, and company autocomplete. Resolves #15.
Operations
clearbitEnrichPersonGET https://person-stream.clearbit.com/v2/people/findclearbitEnrichCompanyGET https://company-stream.clearbit.com/v2/companies/findclearbitCompanyAutocompleteGET https://autocomplete.clearbit.com/v1/companies/suggestCredential
Single API-key credential (
clearbit) authenticating viaAuthorization: Bearer {{apiKey}}header, defined throughdefineApiKeyCredentialfrom@jam-nodes/core. Matches the shape declared in issue #15 exactly.Implementation notes
person-stream/company-streamsubdomains instead of the non-streaming alternatives, because the non-streaming endpoints return202 + webhook callback(unsuitable for synchronous workflow execution). Matches the n8n reference implementation.givenName,familyName,companyDomain) are mapped to Clearbit's snake_case query params (given_name,family_name,company_domain). ThelinkedInfield specifically maps to lowercaselinkedinto match Clearbit's URL convention.name→query. The issue's input field isnamebut Clearbit's URL param isquery; mapped at request-build time.location,employment.title,social.github, etc.) are handled with?? nulland tested explicitly against sparse responses.clearbit-enrich-person.ts,clearbit-enrich-company.ts,clearbit-company-autocomplete.ts, each self-contained — follows the apify / devto precedent.fetchWithRetryutility (default: 3 retries, 1s initial backoff, 30s timeout). No retry/cache/timeout configuration inside node bodies — nodes stay pure per the architectural rule inCLAUDE.md.{ success: false, error }on missing credentials, non-OK responses, malformed responses (missingid), and network failures. They never throw.Files changed
packages/core/src/types/node.ts— extendNodeCredentialswithclearbit?: { apiKey: string }packages/nodes/src/integrations/clearbit/credentials.ts— new,clearbitCredentialpackages/nodes/src/integrations/clearbit/schemas.ts— new, 6 Zod schemas + 6 inferred typespackages/nodes/src/integrations/clearbit/clearbit-enrich-person.ts— new nodepackages/nodes/src/integrations/clearbit/clearbit-enrich-company.ts— new nodepackages/nodes/src/integrations/clearbit/clearbit-company-autocomplete.ts— new nodepackages/nodes/src/integrations/clearbit/index.ts— new barrelpackages/nodes/src/integrations/clearbit/__tests__/clearbit.test.ts— new, 50 testspackages/nodes/src/integrations/index.ts— re-export clearbitpackages/nodes/src/index.ts— add value + type exports, append tobuiltInNodes[]Test coverage (50 tests, all passing)
{apiKey}, schema rejects{}clearbit_enrich_person(13): missing API key, full happy path, endpoint URL, Bearer header, email query param, camelCase→snake_case mapping,linkedIn→linkedinlowercase, omitting absent optionals, nullable response fields, missing nested social objects, 401, 404, missing-id guard, network failureclearbit_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 failureclearbit_company_autocomplete(8): missing API key, happy path, endpoint URL,name→queryparam mapping, Bearer header, empty results, non-OK response, malformed (non-array) response, network failurecontext.credentials.clearbit.apiKeyerror when credentials are absentVerification
mainbaselinetsc --noEmitscoped to clearbit files,integrations/index.ts,nodes/src/index.ts,types/node.ts: zero errors (pre-existing unrelated typecheck errors inapify/,google-sheets/,slack/are untouched)Acceptance criteria (from issue #15)
Closes #15