typespot

The missing type system for your HubSpot objects.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
typespot
000.0.9a year agoa year agoMinified + gzip package size for typespot in KB

Readme

TypeSpot šŸ’«
!npm packagenpm-imgnpm-url !Build Statusbuild-imgbuild-url !Downloadsdownloads-imgdownloads-url !Issuesissues-imgissues-url !Code Coveragecodecov-imgcodecov-url !Commitizen Friendlycommitizen-imgcommitizen-url !Semantic Releasesemantic-release-imgsemantic-release-url
The missing type system for your HubSpot objects.

What?

This package generates explicit type files for all of your object types within your current portal, looking something like:
export type Company = {
    properties: {
        name: string
        some_custom_prop: 'cool' | 'cooler'
        // ... all default and custom props
    }
}

For convienience it also exports the full property definitions:
export const CompanyProperties = [
    {
        name: 'name',
        label: 'Name',
        description: 'Its a name!',
        // ...
    },
    
    // ...
]

Why?

When using @hubspot/api-client with TypeScript, the objects returned are practically black boxes:
class SimplePublicObject {
    properties: {
        [key: string]: string;
    };        
}

So, we have a hard time type checking when reading/writing to the API and we constantly have to reference the web portal. With this package we can develop faster and more confidently.

Usage

Install the package:
npm install typespot

Next, generate your files
npx ts-node typespot <YOUR_ACCESS_TOKEN>

You will see something like:
āœ… Created src/types/Company.ts
āœ… Created src/types/Contact.ts
āœ… Created src/types/Deal.ts
āœ… Created src/types/Product.ts
šŸŸ” 403 Forbidden when reading tickets. Did you forget to assign scopes?
šŸŸ” 403 Forbidden when reading quotes. Did you forget to assign scopes?

Alternatively, you may generate these files programatically:
import { TypeSpot } from 'typespot';
import { Client } from "@hubspot/api-client";

const client = new Client({accessToken: 'secret'})
new TypeSpot({ client }).write()

TODO

missing some object types in CRM
missing custom object in CRM
ALL other types are missing

License

MIT