0.0.9 ā¢ Published 1 year ago
typespot v0.0.9
TypeSpot š«
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