clearbit / clearbit-node

Node library for querying the Clearbit business intelligence APIs
https://clearbit.com/docs
MIT License
69 stars 35 forks source link

Typings? #48

Open tommedema opened 3 years ago

tommedema commented 3 years ago

Are there typescript typings?

FritzTheDev commented 3 years ago

@tommedema, I haven't found any so I'm going to see what the API surface area looks like and try writing some if it's not too big. Feel free to tag me here if you want to check on them.

randalvance commented 3 years ago

Our team is also looking for the official typings for this. Thanks.

FritzTheDev commented 3 years ago

@randalvance @tommedema I'm no longer working on the Typings for this - the API was going to make it hard and the benefit to me wasn't that big. Good luck!

tommedema commented 3 years ago

@randalvance any update on this?

tommedema commented 3 years ago

at bubbles we worked around this by creating a custom typings definition tailored to our use case:

typings/clearbit/index.d.ts


declare function clearbit(apiKey: string): Clearbit.IClearbitClient

/**
 * @see https://stackoverflow.com/a/33392782/45974
 */
declare namespace Clearbit {
  interface IPerson {
    setVersion: (version: '2019-12-19') => void,
  }

  interface IEnrichment {
    find: ({email: string, stream: boolean}) => Promise<Clearbit.IEnrichmentResult>
  }

  interface IEnrichmentResult {
    person: object | null
    company: object | null
  }

  interface IClearbitClient {
    Person: Clearbit.IPerson,
    Enrichment: Clearbit.IEnrichment
  }
}

export = clearbit
wbobeirne commented 3 years ago

Would love to see some official typings from the Clearbit team, especially since the docs have this note about Person and Company:

No attributes are guaranteed to be present

The difference between no key defined, null, empty string, and empty array can be really important! I could do a few responses and guess at what the shape and assurances are of data availability, but having something more dependable would be great.