typespot
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

TypeSpot 💫

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

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

Package Sidebar

Install

npm i typespot

Weekly Downloads

0

Version

0.0.9

License

MIT

Unpacked Size

20.1 kB

Total Files

15

Last publish

Collaborators

  • ajinvise