diff --git a/.gitignore b/.gitignore index 4829686..e93a32a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ +/examples/node_modules +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.DS_Store +.env +.env.local +.env.*.local /models /models/errors /types diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 00daae1..3c4a6cd 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: f81a812c-4cc0-49fc-86b0-dcfbc85954e3 management: docChecksum: 430e7d604ea696a88d6b34a8e18c9ff8 docVersion: v3 - speakeasyVersion: 1.521.1 - generationVersion: 2.558.5 - releaseVersion: 0.1.0 - configChecksum: ced1f77351976ac9d8b161d9f27f05f8 + speakeasyVersion: 1.600.2 + generationVersion: 2.677.3 + releaseVersion: 0.2.0 + configChecksum: bbbd60ebe7e755423004b3672c1b07a7 repoURL: https://github.com/speakeasy-api/hubspot-typescript.git installationURL: https://github.com/speakeasy-api/hubspot-typescript published: true @@ -14,8 +14,8 @@ features: typescript: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.11 - core: 3.21.4 + constsAndDefaults: 0.1.12 + core: 3.21.20 defaultEnabledRetries: 0.1.0 devContainers: 2.90.0 enumUnions: 0.1.0 @@ -23,12 +23,12 @@ features: globalSecurity: 2.82.13 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 - globalServerURLs: 2.82.4 - mcpServer: 0.9.0 + globalServerURLs: 2.82.5 + mcpServer: 0.9.3 nullables: 0.1.1 responseFormat: 0.2.3 retries: 2.83.0 - sdkHooks: 0.2.0 + sdkHooks: 0.3.0 generatedFiles: - .devcontainer/README.md - .devcontainer/devcontainer.json @@ -86,6 +86,10 @@ generatedFiles: - docs/sdks/hubspot/README.md - docs/sdks/search/README.md - eslint.config.mjs + - examples/.env.template + - examples/README.md + - examples/basicGetProperties.example.ts + - examples/package.json - jsr.json - package.json - src/core.ts @@ -170,7 +174,9 @@ generatedFiles: - src/models/components/valuewithtimestamp.ts - src/models/errors/apierror.ts - src/models/errors/httpclienterrors.ts + - src/models/errors/hubspoterror.ts - src/models/errors/index.ts + - src/models/errors/responsevalidationerror.ts - src/models/errors/sdkvalidationerror.ts - src/models/operations/createcontact.ts - src/models/operations/createdeal.ts @@ -204,12 +210,12 @@ examples: speakeasy-default-get-properties: parameters: path: - objectType: "deals" + objectType: "contacts" responses: "200": application/json: {"key": "", "key1": "", "key2": ""} default: - '*/*': "0xDC1CcbAA6F" + '*/*': "0x6AebEB6dfa" getCompany: speakeasy-default-get-company: parameters: @@ -219,22 +225,21 @@ examples: archived: false responses: "200": - application/json: {"associations": {"key": {"paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": []}}, "createdAt": "2025-10-24T12:05:59.595Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2023-04-22T05:13:50.650Z"} + application/json: {"createdAt": "2025-08-25T15:16:09.699Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2025-05-22T12:21:57.653Z"} default: - '*/*': "0xBCBF4Fa1AB" + '*/*': "0x095Bfee7E8" updateCompany: speakeasy-default-update-company: parameters: path: companyId: "" - query: {} requestBody: - application/json: {"properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}} + application/json: {"properties": {"amount": "1500.00", "dealname": "Custom data integrations", "pipeline": "default", "closedate": "2019-12-07T16:50:06.678Z", "dealstage": "presentationscheduled", "hubspot_owner_id": "910901"}} responses: "200": - application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}, "updatedAt": "2019-12-07T16:50:06.678Z"} + application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"} default: - '*/*': "0xb3E6c6BfBC" + '*/*': "0xdceFCcA8Bb" getContact: speakeasy-default-get-contact: parameters: @@ -244,30 +249,30 @@ examples: archived: false responses: "200": - application/json: {"associations": {"key": {"paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": []}}, "createdAt": "2024-08-17T15:34:51.440Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2024-01-04T02:16:38.002Z"} + application/json: {"createdAt": "2024-04-26T22:09:40.861Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2024-05-07T19:22:28.190Z"} default: - '*/*': "0xaE60343E90" + '*/*': "0x8ef9DAF6B0" updateContact: speakeasy-default-update-contact: parameters: path: contactId: "" requestBody: - application/json: {"properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}} + application/json: {"properties": {"amount": "1500.00", "dealname": "Custom data integrations", "pipeline": "default", "closedate": "2019-12-07T16:50:06.678Z", "dealstage": "presentationscheduled", "hubspot_owner_id": "910901"}} responses: "200": - application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}, "updatedAt": "2019-12-07T16:50:06.678Z"} + application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"} default: - '*/*': "0x3b85af6eBc" + '*/*': "0xded1d6FB0E" createContact: speakeasy-default-create-contact: requestBody: application/json: {"associations": [{"types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 2}], "to": {"id": "101"}}], "properties": {"amount": "1500.00", "dealname": "Custom data integrations", "pipeline": "default", "closedate": "2019-12-07T16:50:06.678Z", "dealstage": "presentationscheduled", "hubspot_owner_id": "910901"}} responses: "201": - application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}, "updatedAt": "2019-12-07T16:50:06.678Z"} + application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"} default: - '*/*': "0xCaDC2a12a5" + '*/*': "0x699Faed7d0" getDeal: speakeasy-default-get-deal: parameters: @@ -277,57 +282,56 @@ examples: archived: false responses: "200": - application/json: {"associations": {"key": {"paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": []}, "key1": {"paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"id": "", "type": ""}, {"id": "", "type": ""}, {"id": "", "type": ""}]}}, "createdAt": "2023-07-20T20:21:19.136Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2024-03-20T16:06:40.704Z"} + application/json: {"createdAt": "2023-09-13T04:14:42.703Z", "id": "", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2024-11-30T01:20:41.885Z"} default: - '*/*': "0xd7Dbec5428" + '*/*': "0x23d01cBbaF" updateDeal: speakeasy-default-update-deal: parameters: path: dealId: "" - query: {} requestBody: - application/json: {"properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}} + application/json: {"properties": {"amount": "1500.00", "dealname": "Custom data integrations", "pipeline": "default", "closedate": "2019-12-07T16:50:06.678Z", "dealstage": "presentationscheduled", "hubspot_owner_id": "910901"}} responses: "200": - application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}, "updatedAt": "2019-12-07T16:50:06.678Z"} + application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"} default: - '*/*': "0xbd6bf0D753" + '*/*': "0xa54Ebb05D3" createDeal: speakeasy-default-create-deal: requestBody: application/json: {"associations": [{"types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 2}], "to": {"id": "101"}}], "properties": {"amount": "1500.00", "dealname": "Custom data integrations", "pipeline": "default", "closedate": "2019-12-07T16:50:06.678Z", "dealstage": "presentationscheduled", "hubspot_owner_id": "910901"}} responses: "201": - application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"property_date": "1572480000000", "property_radio": "option_1", "property_number": "17", "property_string": "value", "property_checkbox": "false", "property_dropdown": "choice_b", "property_multiple_checkboxes": "chocolate;strawberry"}, "updatedAt": "2019-12-07T16:50:06.678Z"} + application/json: {"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"} default: - '*/*': "0xad38C8Ad0A" + '*/*': "0xCB53a70BeA" searchCompanies: speakeasy-default-search-companies: requestBody: application/json: {} responses: "200": - application/json: {"total": 417690, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} + application/json: {"total": 243268, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} default: - '*/*': "0x35e6bBbc27" + '*/*': "0x7194B2Fbdc" searchContacts: speakeasy-default-search-contacts: requestBody: application/json: {} responses: "200": - application/json: {"total": 748860, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} + application/json: {"total": 473738, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} default: - '*/*': "0x2f94F8F016" + '*/*': "0xD472AaCEA0" searchDeals: speakeasy-default-search-deals: requestBody: application/json: {} responses: "200": - application/json: {"total": 265805, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} + application/json: {"total": 99162, "paging": {"next": {"link": "?after=NTI1Cg%3D%3D", "after": "NTI1Cg%3D%3D"}}, "results": [{"createdAt": "2019-10-30T03:30:17.883Z", "archived": false, "id": "512", "properties": {"amount": "1500.00", "closedate": "2019-12-07T16:50:06.678Z", "createdate": "2019-10-30T03:30:17.883Z", "dealname": "Custom data integrations", "dealstage": "presentationscheduled", "hs_lastmodifieddate": "2019-12-07T16:50:06.678Z", "hubspot_owner_id": "910901", "pipeline": "default"}, "updatedAt": "2019-12-07T16:50:06.678Z"}]} default: - '*/*': "0x943fFbCFA3" -examplesVersion: 1.0.0 + '*/*': "0x1bbfBe91ad" +examplesVersion: 1.0.2 generatedTests: {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 8658bed..997657a 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -7,6 +7,7 @@ generation: maintainOpenAPIOrder: true usageSnippets: optionalPropertyRendering: withExample + sdkInitStyle: constructor useClassNamesForArrayFields: true fixes: nameResolutionDec2023: true @@ -14,18 +15,25 @@ generation: parameterOrderingFeb2024: true requestResponseComponentNamesFeb2024: true securityFeb2025: true + sharedErrorComponentsApr2025: false auth: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: true + tests: + generateTests: true + generateNewTests: false + skipResponseBodyAssertions: false typescript: - version: 0.1.0 + version: 0.2.0 additionalDependencies: dependencies: {} devDependencies: {} peerDependencies: {} additionalPackageJSON: {} author: speakeasyapi + baseErrorName: HubspotError clientServerStatusCodesAsErrors: true + constFieldsAlwaysOptional: true defaultErrorName: APIError enableCustomCodeRegions: false enableMCPServer: true @@ -34,6 +42,7 @@ typescript: envVarPrefix: HUBSPOT flattenGlobalSecurity: true flatteningOrder: parameters-first + generateExamples: true imports: option: openapi paths: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index a2da036..84f6338 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.521.1 +speakeasyVersion: 1.600.2 sources: CRM: sourceNamespace: crm @@ -9,20 +9,20 @@ sources: - v3 HubspotCRM: sourceNamespace: hubspot-crm - sourceRevisionDigest: sha256:068f049648f508cd2c1f0b3f74fdec83a2920b10763541b84a05644ba5fac7f9 - sourceBlobDigest: sha256:fd3bb26f0d19170b271fae7398ffb1b2dbe48799b6e7c4dee95ec5c58302f332 + sourceRevisionDigest: sha256:bdaa622c04c7175412a08b756862795f1d99e297146f8e2b525f3963e534147e + sourceBlobDigest: sha256:b1d0f16211f77123ade749fadc389b583fdf73c524f6bf7014da1fae2f4b2d6a tags: - latest - - speakeasy-sdk-regen-1742493224 + - speakeasy-sdk-regen-1743711404 - v3 targets: hubspot: source: HubspotCRM sourceNamespace: hubspot-crm - sourceRevisionDigest: sha256:068f049648f508cd2c1f0b3f74fdec83a2920b10763541b84a05644ba5fac7f9 - sourceBlobDigest: sha256:fd3bb26f0d19170b271fae7398ffb1b2dbe48799b6e7c4dee95ec5c58302f332 + sourceRevisionDigest: sha256:bdaa622c04c7175412a08b756862795f1d99e297146f8e2b525f3963e534147e + sourceBlobDigest: sha256:b1d0f16211f77123ade749fadc389b583fdf73c524f6bf7014da1fae2f4b2d6a codeSamplesNamespace: hubspot-crm-typescript-code-samples - codeSamplesRevisionDigest: sha256:d61859db7b587ca10a3a1abaff25b520db3c9e1e3f8cfde32e27cd069c6e5a2a + codeSamplesRevisionDigest: sha256:9d63f8a7ebe06cb08da4c6542e29daea2a82959c4df9bb24a952e55d7fc476c3 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/FUNCTIONS.md b/FUNCTIONS.md index 4dfef73..7b0d8f7 100644 --- a/FUNCTIONS.md +++ b/FUNCTIONS.md @@ -21,7 +21,6 @@ specific category of applications. ```typescript import { HubspotCore } from "mcp-hubspot/core.js"; import { basicGetProperties } from "mcp-hubspot/funcs/basicGetProperties.js"; -import { SDKValidationError } from "mcp-hubspot/models/errors/sdkvalidationerror.js"; // Use `HubspotCore` for best tree-shaking performance. // You can create one instance of it to use across an application. @@ -31,30 +30,14 @@ const hubspot = new HubspotCore({ async function run() { const res = await basicGetProperties(hubspot, { - objectType: "deals", + objectType: "contacts", }); - - switch (true) { - case res.ok: - // The success case will be handled outside of the switch block - break; - case res.error instanceof SDKValidationError: - // Pretty-print validation errors. - return console.log(res.error.pretty()); - case res.error instanceof Error: - return console.log(res.error); - default: - // TypeScript's type checking will fail on the following line if the above - // cases were not exhaustive. - res.error satisfies never; - throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicGetProperties failed:", res.error); } - - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); diff --git a/README.md b/README.md index f60284a..3a9f688 100644 --- a/README.md +++ b/README.md @@ -181,10 +181,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } @@ -214,10 +213,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } @@ -300,7 +298,7 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }, { retries: { strategy: "backoff", @@ -314,7 +312,6 @@ async function run() { }, }); - // Handle the result console.log(result); } @@ -342,10 +339,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } @@ -357,51 +353,38 @@ run(); ## Error Handling -If the request fails due to, for example 4XX or 5XX status codes, it will throw a `APIError`. +[`HubspotError`](./src/models/errors/hubspoterror.ts) is the base class for all HTTP error responses. It has the following properties: -| Error Type | Status Code | Content Type | -| --------------- | ----------- | ------------ | -| errors.APIError | 4XX, 5XX | \*/\* | +| Property | Type | Description | +| ------------------- | ---------- | ------------------------------------------------------ | +| `error.message` | `string` | Error message | +| `error.statusCode` | `number` | HTTP response status code eg `404` | +| `error.headers` | `Headers` | HTTP response headers | +| `error.body` | `string` | HTTP body. Can be empty string if no body is returned. | +| `error.rawResponse` | `Response` | Raw HTTP response | +### Example ```typescript import { Hubspot } from "mcp-hubspot"; -import { SDKValidationError } from "mcp-hubspot/models/errors"; +import * as errors from "mcp-hubspot/models/errors"; const hubspot = new Hubspot({ hubspotToken: process.env["HUBSPOT_HUBSPOT_TOKEN"] ?? "", }); async function run() { - let result; try { - result = await hubspot.basic.getProperties({ - objectType: "deals", + const result = await hubspot.basic.getProperties({ + objectType: "contacts", }); - // Handle the result console.log(result); - } catch (err) { - switch (true) { - // The server response does not match the expected SDK schema - case (err instanceof SDKValidationError): - { - // Pretty-print will provide a human-readable multi-line error message - console.error(err.pretty()); - // Raw value may also be inspected - console.error(err.rawValue); - return; - } - apierror.js; - // Server returned an error status code or an unknown content type - case (err instanceof APIError): { - console.error(err.statusCode); - console.error(err.rawResponse.body); - return; - } - default: { - // Other errors such as network errors, see HTTPClientErrors for more details - throw err; - } + } catch (error) { + if (error instanceof errors.HubspotError) { + console.log(error.message); + console.log(error.statusCode); + console.log(error.body); + console.log(error.headers); } } } @@ -410,17 +393,26 @@ run(); ``` -Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging. +### Error Classes +**Primary error:** +* [`HubspotError`](./src/models/errors/hubspoterror.ts): The base class for HTTP error responses. + +
Less common errors (6) + +
-In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module: +**Network errors:** +* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server. +* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal. +* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client. +* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid. +* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error. -| HTTP Client Error | Description | -| ---------------------------------------------------- | ---------------------------------------------------- | -| RequestAbortedError | HTTP request was aborted by the client | -| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | -| ConnectionError | HTTP client was unable to make a request to a server | -| InvalidRequestError | Any input used to create a request is invalid | -| UnexpectedClientError | Unrecognised or unexpected error | + +**Inherit from [`HubspotError`](./src/models/errors/hubspoterror.ts)**: +* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string. + +
@@ -439,10 +431,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } diff --git a/RELEASES.md b/RELEASES.md index 56553b9..bc5ec1d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -8,4 +8,14 @@ Based on: ### Generated - [typescript v0.1.0] . ### Releases -- [NPM v0.1.0] https://www.npmjs.com/package/mcp-hubspot/v/0.1.0 - . \ No newline at end of file +- [NPM v0.1.0] https://www.npmjs.com/package/mcp-hubspot/v/0.1.0 - . + +## 2025-08-11 00:19:52 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.600.2 (2.677.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.2.0] . +### Releases +- [NPM v0.2.0] https://www.npmjs.com/package/mcp-hubspot/v/0.2.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index d3a6648..5607053 100644 --- a/USAGE.md +++ b/USAGE.md @@ -8,10 +8,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } diff --git a/docs/models/components/associationcategory.md b/docs/models/components/associationcategory.md index 456d300..107df11 100644 --- a/docs/models/components/associationcategory.md +++ b/docs/models/components/associationcategory.md @@ -5,7 +5,7 @@ ```typescript import { AssociationCategory } from "mcp-hubspot/models/components"; -let value: AssociationCategory = "USER_DEFINED"; +let value: AssociationCategory = "HUBSPOT_DEFINED"; ``` ## Values diff --git a/docs/models/components/associationspec.md b/docs/models/components/associationspec.md index 3b005ab..faf951e 100644 --- a/docs/models/components/associationspec.md +++ b/docs/models/components/associationspec.md @@ -7,7 +7,7 @@ import { AssociationSpec } from "mcp-hubspot/models/components"; let value: AssociationSpec = { associationCategory: "USER_DEFINED", - associationTypeId: 652103, + associationTypeId: 754129, }; ``` diff --git a/docs/models/components/collectionresponseassociatedid.md b/docs/models/components/collectionresponseassociatedid.md index 1f8da0b..3f8b019 100644 --- a/docs/models/components/collectionresponseassociatedid.md +++ b/docs/models/components/collectionresponseassociatedid.md @@ -12,12 +12,7 @@ let value: CollectionResponseAssociatedId = { after: "NTI1Cg%3D%3D", }, }, - results: [ - { - id: "", - type: "", - }, - ], + results: [], }; ``` diff --git a/docs/models/components/collectionresponsewithtotalsimplepublicobjectforwardpaging.md b/docs/models/components/collectionresponsewithtotalsimplepublicobjectforwardpaging.md index 5e7f002..b977c46 100644 --- a/docs/models/components/collectionresponsewithtotalsimplepublicobjectforwardpaging.md +++ b/docs/models/components/collectionresponsewithtotalsimplepublicobjectforwardpaging.md @@ -6,7 +6,7 @@ import { CollectionResponseWithTotalSimplePublicObjectForwardPaging } from "mcp-hubspot/models/components"; let value: CollectionResponseWithTotalSimplePublicObjectForwardPaging = { - total: 431418, + total: 371377, paging: { next: { link: "?after=NTI1Cg%3D%3D", diff --git a/docs/models/components/filter.md b/docs/models/components/filter.md index e4c624f..a2311f8 100644 --- a/docs/models/components/filter.md +++ b/docs/models/components/filter.md @@ -7,7 +7,7 @@ import { Filter } from "mcp-hubspot/models/components"; let value: Filter = { propertyName: "", - operator: "GTE", + operator: "IN", }; ``` diff --git a/docs/models/components/filtergroup.md b/docs/models/components/filtergroup.md index d0d05ef..92b98d9 100644 --- a/docs/models/components/filtergroup.md +++ b/docs/models/components/filtergroup.md @@ -9,7 +9,7 @@ let value: FilterGroup = { filters: [ { propertyName: "", - operator: "CONTAINS_TOKEN", + operator: "LT", }, ], }; diff --git a/docs/models/components/operator.md b/docs/models/components/operator.md index 573c908..c661f05 100644 --- a/docs/models/components/operator.md +++ b/docs/models/components/operator.md @@ -7,7 +7,7 @@ null ```typescript import { Operator } from "mcp-hubspot/models/components"; -let value: Operator = "GT"; +let value: Operator = "BETWEEN"; ``` ## Values diff --git a/docs/models/components/publicassociationsforobject.md b/docs/models/components/publicassociationsforobject.md index 755c099..6e8861a 100644 --- a/docs/models/components/publicassociationsforobject.md +++ b/docs/models/components/publicassociationsforobject.md @@ -8,8 +8,8 @@ import { PublicAssociationsForObject } from "mcp-hubspot/models/components"; let value: PublicAssociationsForObject = { types: [ { - associationCategory: "USER_DEFINED", - associationTypeId: 590873, + associationCategory: "HUBSPOT_DEFINED", + associationTypeId: 551132, }, ], to: { diff --git a/docs/models/components/simplepublicobjectwithassociations.md b/docs/models/components/simplepublicobjectwithassociations.md index 26ba23a..df787de 100644 --- a/docs/models/components/simplepublicobjectwithassociations.md +++ b/docs/models/components/simplepublicobjectwithassociations.md @@ -6,7 +6,7 @@ import { SimplePublicObjectWithAssociations } from "mcp-hubspot/models/components"; let value: SimplePublicObjectWithAssociations = { - createdAt: new Date("2024-04-14T22:19:54.875Z"), + createdAt: new Date("2025-06-21T16:54:22.539Z"), id: "", properties: { "amount": "1500.00", @@ -18,7 +18,7 @@ let value: SimplePublicObjectWithAssociations = { "hubspot_owner_id": "910901", "pipeline": "default", }, - updatedAt: new Date("2023-05-29T11:30:35.227Z"), + updatedAt: new Date("2024-10-01T05:33:36.814Z"), }; ``` diff --git a/docs/models/components/valuewithtimestamp.md b/docs/models/components/valuewithtimestamp.md index c1e60da..e4af599 100644 --- a/docs/models/components/valuewithtimestamp.md +++ b/docs/models/components/valuewithtimestamp.md @@ -8,7 +8,7 @@ import { ValueWithTimestamp } from "mcp-hubspot/models/components"; let value: ValueWithTimestamp = { sourceType: "", value: "", - timestamp: new Date("2023-11-23T22:01:05.887Z"), + timestamp: new Date("2023-03-21T16:01:07.532Z"), }; ``` diff --git a/docs/models/operations/createcontactresponse.md b/docs/models/operations/createcontactresponse.md index d80f09b..c3dd578 100644 --- a/docs/models/operations/createcontactresponse.md +++ b/docs/models/operations/createcontactresponse.md @@ -27,6 +27,6 @@ const value: components.SimplePublicObject = { ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xe5a532e348"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/createdealresponse.md b/docs/models/operations/createdealresponse.md index 8f9213f..50ab258 100644 --- a/docs/models/operations/createdealresponse.md +++ b/docs/models/operations/createdealresponse.md @@ -27,6 +27,6 @@ const value: components.SimplePublicObject = { ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xcE7e2f64c0"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/getcompanyresponse.md b/docs/models/operations/getcompanyresponse.md index af4cd47..53ee8b3 100644 --- a/docs/models/operations/getcompanyresponse.md +++ b/docs/models/operations/getcompanyresponse.md @@ -7,7 +7,7 @@ ```typescript const value: components.SimplePublicObjectWithAssociations = { - createdAt: new Date("2024-09-14T13:50:38.886Z"), + createdAt: new Date("2024-11-28T12:17:43.309Z"), id: "", properties: { "amount": "1500.00", @@ -19,13 +19,13 @@ const value: components.SimplePublicObjectWithAssociations = { "hubspot_owner_id": "910901", "pipeline": "default", }, - updatedAt: new Date("2025-10-11T10:53:38.306Z"), + updatedAt: new Date("2024-05-22T04:57:54.841Z"), }; ``` ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x110CBDFBaB"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/getcontactresponse.md b/docs/models/operations/getcontactresponse.md index 4e8969c..373ef52 100644 --- a/docs/models/operations/getcontactresponse.md +++ b/docs/models/operations/getcontactresponse.md @@ -7,7 +7,7 @@ ```typescript const value: components.SimplePublicObjectWithAssociations = { - createdAt: new Date("2023-01-21T14:14:48.878Z"), + createdAt: new Date("2024-11-28T12:17:43.309Z"), id: "", properties: { "amount": "1500.00", @@ -19,13 +19,13 @@ const value: components.SimplePublicObjectWithAssociations = { "hubspot_owner_id": "910901", "pipeline": "default", }, - updatedAt: new Date("2024-11-07T22:17:02.814Z"), + updatedAt: new Date("2024-05-22T04:57:54.841Z"), }; ``` ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xddEf79f1ee"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/getdealresponse.md b/docs/models/operations/getdealresponse.md index fa6cf21..bf53647 100644 --- a/docs/models/operations/getdealresponse.md +++ b/docs/models/operations/getdealresponse.md @@ -7,7 +7,7 @@ ```typescript const value: components.SimplePublicObjectWithAssociations = { - createdAt: new Date("2025-06-18T19:24:21.305Z"), + createdAt: new Date("2024-11-28T12:17:43.309Z"), id: "", properties: { "amount": "1500.00", @@ -19,13 +19,13 @@ const value: components.SimplePublicObjectWithAssociations = { "hubspot_owner_id": "910901", "pipeline": "default", }, - updatedAt: new Date("2023-04-17T10:09:07.050Z"), + updatedAt: new Date("2024-05-22T04:57:54.841Z"), }; ``` ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xC2FaFdA062"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/getpropertiesrequest.md b/docs/models/operations/getpropertiesrequest.md index 319da33..0c5d37d 100644 --- a/docs/models/operations/getpropertiesrequest.md +++ b/docs/models/operations/getpropertiesrequest.md @@ -6,7 +6,7 @@ import { GetPropertiesRequest } from "mcp-hubspot/models/operations"; let value: GetPropertiesRequest = { - objectType: "deals", + objectType: "contacts", }; ``` diff --git a/docs/models/operations/getpropertiesresponse.md b/docs/models/operations/getpropertiesresponse.md index ec607c2..eaa9302 100644 --- a/docs/models/operations/getpropertiesresponse.md +++ b/docs/models/operations/getpropertiesresponse.md @@ -8,12 +8,14 @@ ```typescript const value: { [k: string]: any } = { "key": "", + "key1": "", + "key2": "", }; ``` ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xdb9e9DF8Bb"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/objecttype.md b/docs/models/operations/objecttype.md index f8a012b..436909d 100644 --- a/docs/models/operations/objecttype.md +++ b/docs/models/operations/objecttype.md @@ -7,7 +7,7 @@ The type of the object for which to retrieve properties. ```typescript import { ObjectType } from "mcp-hubspot/models/operations"; -let value: ObjectType = "companies"; +let value: ObjectType = "contacts"; ``` ## Values diff --git a/docs/models/operations/searchcompaniesresponse.md b/docs/models/operations/searchcompaniesresponse.md index 57c93fd..f4b8a83 100644 --- a/docs/models/operations/searchcompaniesresponse.md +++ b/docs/models/operations/searchcompaniesresponse.md @@ -8,7 +8,7 @@ ```typescript const value: components.CollectionResponseWithTotalSimplePublicObjectForwardPaging = { - total: 828940, + total: 371377, paging: { next: { link: "?after=NTI1Cg%3D%3D", @@ -39,6 +39,6 @@ const value: ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x0e5AF5cdc4"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/searchcontactsresponse.md b/docs/models/operations/searchcontactsresponse.md index 1f9b196..b1e5e54 100644 --- a/docs/models/operations/searchcontactsresponse.md +++ b/docs/models/operations/searchcontactsresponse.md @@ -8,7 +8,7 @@ ```typescript const value: components.CollectionResponseWithTotalSimplePublicObjectForwardPaging = { - total: 952749, + total: 371377, paging: { next: { link: "?after=NTI1Cg%3D%3D", @@ -39,6 +39,6 @@ const value: ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x9Cf6B8DcDf"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/searchdealsresponse.md b/docs/models/operations/searchdealsresponse.md index db9454c..e5cb79a 100644 --- a/docs/models/operations/searchdealsresponse.md +++ b/docs/models/operations/searchdealsresponse.md @@ -8,7 +8,7 @@ ```typescript const value: components.CollectionResponseWithTotalSimplePublicObjectForwardPaging = { - total: 725255, + total: 371377, paging: { next: { link: "?after=NTI1Cg%3D%3D", @@ -39,6 +39,6 @@ const value: ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0xbFe9d06e6d"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/updatecompanyresponse.md b/docs/models/operations/updatecompanyresponse.md index b952837..95d47a9 100644 --- a/docs/models/operations/updatecompanyresponse.md +++ b/docs/models/operations/updatecompanyresponse.md @@ -27,6 +27,6 @@ const value: components.SimplePublicObject = { ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x2e3Eb95Bac"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/updatecontactresponse.md b/docs/models/operations/updatecontactresponse.md index b64f945..4e54d41 100644 --- a/docs/models/operations/updatecontactresponse.md +++ b/docs/models/operations/updatecontactresponse.md @@ -27,6 +27,6 @@ const value: components.SimplePublicObject = { ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x4268c9F243"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/models/operations/updatedealresponse.md b/docs/models/operations/updatedealresponse.md index d0d2bdd..2797620 100644 --- a/docs/models/operations/updatedealresponse.md +++ b/docs/models/operations/updatedealresponse.md @@ -27,6 +27,6 @@ const value: components.SimplePublicObject = { ### `Uint8Array` ```typescript -const value: Uint8Array = new TextEncoder().encode("0x62691fc5b2"); +const value: Uint8Array = new TextEncoder().encode("0xdC7D3f4be0"); ``` diff --git a/docs/sdks/basic/README.md b/docs/sdks/basic/README.md index 211df99..4b5242c 100644 --- a/docs/sdks/basic/README.md +++ b/docs/sdks/basic/README.md @@ -21,6 +21,7 @@ Get the list of all properties that are available on any hubspot object. ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -30,10 +31,9 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.basic.getProperties({ - objectType: "deals", + objectType: "contacts", }); - // Handle the result console.log(result); } @@ -56,17 +56,14 @@ const hubspot = new HubspotCore({ async function run() { const res = await basicGetProperties(hubspot, { - objectType: "deals", + objectType: "contacts", }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicGetProperties failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -97,6 +94,7 @@ Retrieve a company by its ID (`companyId`) or by a unique property (`idProperty` ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -109,7 +107,6 @@ async function run() { companyId: "", }); - // Handle the result console.log(result); } @@ -134,15 +131,12 @@ async function run() { const res = await basicGetCompany(hubspot, { companyId: "", }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicGetCompany failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -173,6 +167,7 @@ Update a company by ID (`companyId`) or unique property value (`idProperty`). Pr ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -185,18 +180,16 @@ async function run() { companyId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - // Handle the result console.log(result); } @@ -222,25 +215,21 @@ async function run() { companyId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicUpdateCompany failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -271,6 +260,7 @@ Retrieve a contact by its ID (`contactId`) or by a unique property (`idProperty` ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -283,7 +273,6 @@ async function run() { contactId: "", }); - // Handle the result console.log(result); } @@ -308,15 +297,12 @@ async function run() { const res = await basicGetContact(hubspot, { contactId: "", }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicGetContact failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -347,6 +333,7 @@ Update a contact by ID (`contactId`) or unique property value (`idProperty`). Pr ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -359,18 +346,16 @@ async function run() { contactId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - // Handle the result console.log(result); } @@ -396,25 +381,21 @@ async function run() { contactId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicUpdateContact failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -445,6 +426,7 @@ Create a single contact. Include a `properties` object to define [property value ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -477,7 +459,6 @@ async function run() { }, }); - // Handle the result console.log(result); } @@ -522,15 +503,12 @@ async function run() { "hubspot_owner_id": "910901", }, }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicCreateContact failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -561,6 +539,7 @@ Read a Deal Object identified by `{dealId}`. `{dealId}` refers to the internal o ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -573,7 +552,6 @@ async function run() { dealId: "", }); - // Handle the result console.log(result); } @@ -598,15 +576,12 @@ async function run() { const res = await basicGetDeal(hubspot, { dealId: "", }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicGetDeal failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -637,6 +612,7 @@ Perform a partial update of an Object identified by `{dealId}`. `{dealId}` refer ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -649,18 +625,16 @@ async function run() { dealId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - // Handle the result console.log(result); } @@ -686,25 +660,21 @@ async function run() { dealId: "", simplePublicObjectInput: { properties: { - "property_date": "1572480000000", - "property_radio": "option_1", - "property_number": "17", - "property_string": "value", - "property_checkbox": "false", - "property_dropdown": "choice_b", - "property_multiple_checkboxes": "chocolate;strawberry", + "amount": "1500.00", + "dealname": "Custom data integrations", + "pipeline": "default", + "closedate": "2019-12-07T16:50:06.678Z", + "dealstage": "presentationscheduled", + "hubspot_owner_id": "910901", }, }, }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicUpdateDeal failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -735,6 +705,7 @@ Create a deal with the given properties and return a copy of the object, includi ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -767,7 +738,6 @@ async function run() { }, }); - // Handle the result console.log(result); } @@ -812,15 +782,12 @@ async function run() { "hubspot_owner_id": "910901", }, }); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("basicCreateDeal failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); diff --git a/docs/sdks/search/README.md b/docs/sdks/search/README.md index 23bf370..d007e7b 100644 --- a/docs/sdks/search/README.md +++ b/docs/sdks/search/README.md @@ -15,6 +15,7 @@ Search for companies by filtering on properties, searching through associations, ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -25,7 +26,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchCompanies({}); - // Handle the result console.log(result); } @@ -48,15 +48,12 @@ const hubspot = new HubspotCore({ async function run() { const res = await searchSearchCompanies(hubspot, {}); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("searchSearchCompanies failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -87,6 +84,7 @@ Search for contacts by filtering on properties, searching through associations, ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -97,7 +95,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchContacts({}); - // Handle the result console.log(result); } @@ -120,15 +117,12 @@ const hubspot = new HubspotCore({ async function run() { const res = await searchSearchContacts(hubspot, {}); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("searchSearchContacts failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); @@ -157,6 +151,7 @@ run(); ### Example Usage + ```typescript import { Hubspot } from "mcp-hubspot"; @@ -167,7 +162,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchDeals({}); - // Handle the result console.log(result); } @@ -190,15 +184,12 @@ const hubspot = new HubspotCore({ async function run() { const res = await searchSearchDeals(hubspot, {}); - - if (!res.ok) { - throw res.error; + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("searchSearchDeals failed:", res.error); } - - const { value: result } = res; - - // Handle the result - console.log(result); } run(); diff --git a/eslint.config.mjs b/eslint.config.mjs index 3483f71..67bccfe 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -11,6 +11,7 @@ export default [ { rules: { "no-constant-condition": "off", + "no-useless-escape": "off", // Handled by typescript compiler "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-explicit-any": "off", diff --git a/examples/.env.template b/examples/.env.template new file mode 100644 index 0000000..6062f1c --- /dev/null +++ b/examples/.env.template @@ -0,0 +1,14 @@ +# mcp-hubspot SDK Environment Variables +# Copy this file to .env and fill in your actual values +# DO NOT commit the .env file to version control + +# Security Configuration +# The SDK supports loading security credentials from environment variables +# with the prefix: HUBSPOT_ +# +# Security environment variables: +HUBSPOT_HUBSPOT_TOKEN=your_hubspot_token_here + +# Debug Configuration +# Enable HTTP request/response logging for debugging +HUBSPOT_DEBUG=false diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..63975a9 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,31 @@ +# mcp-hubspot Examples + +This directory contains example scripts demonstrating how to use the mcp-hubspot SDK. + +## Prerequisites + +- Node.js (v18 or higher) +- npm + +## Setup + +1. Copy `.env.template` to `.env`: + ```bash + cp .env.template .env + ``` + +2. Edit `.env` and add your actual credentials (API keys, tokens, etc.) + +## Running the Examples + +To run an example file from the examples directory: + +```bash +npm run build && npx tsx example.ts +``` + +## Creating new examples + +Duplicate an existing example file, they won't be overwritten by the generation process. + + diff --git a/examples/basicGetProperties.example.ts b/examples/basicGetProperties.example.ts new file mode 100644 index 0000000..b83bae1 --- /dev/null +++ b/examples/basicGetProperties.example.ts @@ -0,0 +1,28 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import dotenv from "dotenv"; +dotenv.config(); +/** + * Example usage of the mcp-hubspot SDK + * + * To run this example from the examples directory: + * npm run build && npx tsx basicGetProperties.ts + */ + +import { Hubspot } from "mcp-hubspot"; + +const hubspot = new Hubspot({ + hubspotToken: process.env["HUBSPOT_HUBSPOT_TOKEN"] ?? "", +}); + +async function main() { + const result = await hubspot.getProperties({ + objectType: "contacts", + }); + + console.log(result); +} + +main().catch(console.error); diff --git a/examples/package-lock.json b/examples/package-lock.json new file mode 100644 index 0000000..031af14 --- /dev/null +++ b/examples/package-lock.json @@ -0,0 +1,628 @@ +{ + "name": "mcp-hubspot-examples", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "mcp-hubspot-examples", + "version": "1.0.0", + "dependencies": { + "mcp-hubspot": "file:.." + }, + "devDependencies": { + "@types/node": "^20.0.0", + "dotenv": "^16.4.5", + "tsx": "^4.19.2" + } + }, + "..": { + "name": "mcp-hubspot", + "version": "0.2.0", + "dependencies": { + "zod": "^3.20.0" + }, + "bin": { + "mcp": "bin/mcp-server.js" + }, + "devDependencies": { + "@eslint/js": "^9.19.0", + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0", + "@stricli/core": "^1.1.1", + "@types/express": "^4.17.21", + "bun": "1.2.17", + "bun-types": "1.2.17", + "eslint": "^9.19.0", + "express": "^4.21.2", + "globals": "^15.14.0", + "tshy": "^2.0.0", + "typescript": "~5.8.3", + "typescript-eslint": "^8.26.0" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/sdk": { + "optional": true + } + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.8.tgz", + "integrity": "sha512-urAvrUedIqEiFR3FYSLTWQgLu5tb+m0qZw0NBEasUeo6wuqatkMDaRT+1uABiGXEu5vqgPd7FGE1BhsAIy9QVA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.8.tgz", + "integrity": "sha512-RONsAvGCz5oWyePVnLdZY/HHwA++nxYWIX1atInlaW6SEkwq6XkP3+cb825EUcRs5Vss/lGh/2YxAb5xqc07Uw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.8.tgz", + "integrity": "sha512-OD3p7LYzWpLhZEyATcTSJ67qB5D+20vbtr6vHlHWSQYhKtzUYrETuWThmzFpZtFsBIxRvhO07+UgVA9m0i/O1w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.8.tgz", + "integrity": "sha512-yJAVPklM5+4+9dTeKwHOaA+LQkmrKFX96BM0A/2zQrbS6ENCmxc4OVoBs5dPkCCak2roAD+jKCdnmOqKszPkjA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.8.tgz", + "integrity": "sha512-Jw0mxgIaYX6R8ODrdkLLPwBqHTtYHJSmzzd+QeytSugzQ0Vg4c5rDky5VgkoowbZQahCbsv1rT1KW72MPIkevw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.8.tgz", + "integrity": "sha512-Vh2gLxxHnuoQ+GjPNvDSDRpoBCUzY4Pu0kBqMBDlK4fuWbKgGtmDIeEC081xi26PPjn+1tct+Bh8FjyLlw1Zlg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.8.tgz", + "integrity": "sha512-YPJ7hDQ9DnNe5vxOm6jaie9QsTwcKedPvizTVlqWG9GBSq+BuyWEDazlGaDTC5NGU4QJd666V0yqCBL2oWKPfA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.8.tgz", + "integrity": "sha512-MmaEXxQRdXNFsRN/KcIimLnSJrk2r5H8v+WVafRWz5xdSVmWLoITZQXcgehI2ZE6gioE6HirAEToM/RvFBeuhw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.8.tgz", + "integrity": "sha512-FuzEP9BixzZohl1kLf76KEVOsxtIBFwCaLupVuk4eFVnOZfU+Wsn+x5Ryam7nILV2pkq2TqQM9EZPsOBuMC+kg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.8.tgz", + "integrity": "sha512-WIgg00ARWv/uYLU7lsuDK00d/hHSfES5BzdWAdAig1ioV5kaFNrtK8EqGcUBJhYqotlUByUKz5Qo6u8tt7iD/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.8.tgz", + "integrity": "sha512-A1D9YzRX1i+1AJZuFFUMP1E9fMaYY+GnSQil9Tlw05utlE86EKTUA7RjwHDkEitmLYiFsRd9HwKBPEftNdBfjg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.8.tgz", + "integrity": "sha512-O7k1J/dwHkY1RMVvglFHl1HzutGEFFZ3kNiDMSOyUrB7WcoHGf96Sh+64nTRT26l3GMbCW01Ekh/ThKM5iI7hQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.8.tgz", + "integrity": "sha512-uv+dqfRazte3BzfMp8PAQXmdGHQt2oC/y2ovwpTteqrMx2lwaksiFZ/bdkXJC19ttTvNXBuWH53zy/aTj1FgGw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.8.tgz", + "integrity": "sha512-GyG0KcMi1GBavP5JgAkkstMGyMholMDybAf8wF5A70CALlDM2p/f7YFE7H92eDeH/VBtFJA5MT4nRPDGg4JuzQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.8.tgz", + "integrity": "sha512-rAqDYFv3yzMrq7GIcen3XP7TUEG/4LK86LUPMIz6RT8A6pRIDn0sDcvjudVZBiiTcZCY9y2SgYX2lgK3AF+1eg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.8.tgz", + "integrity": "sha512-Xutvh6VjlbcHpsIIbwY8GVRbwoviWT19tFhgdA7DlenLGC/mbc3lBoVb7jxj9Z+eyGqvcnSyIltYUrkKzWqSvg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.8.tgz", + "integrity": "sha512-ASFQhgY4ElXh3nDcOMTkQero4b1lgubskNlhIfJrsH5OKZXDpUAKBlNS0Kx81jwOBp+HCeZqmoJuihTv57/jvQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.8.tgz", + "integrity": "sha512-d1KfruIeohqAi6SA+gENMuObDbEjn22olAR7egqnkCD9DGBG0wsEARotkLgXDu6c4ncgWTZJtN5vcgxzWRMzcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.8.tgz", + "integrity": "sha512-nVDCkrvx2ua+XQNyfrujIG38+YGyuy2Ru9kKVNyh5jAys6n+l44tTtToqHjino2My8VAY6Lw9H7RI73XFi66Cg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.8.tgz", + "integrity": "sha512-j8HgrDuSJFAujkivSMSfPQSAa5Fxbvk4rgNAS5i3K+r8s1X0p1uOO2Hl2xNsGFppOeHOLAVgYwDVlmxhq5h+SQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.8.tgz", + "integrity": "sha512-1h8MUAwa0VhNCDp6Af0HToI2TJFAn1uqT9Al6DJVzdIBAd21m/G0Yfc77KDM3uF3T/YaOgQq3qTJHPbTOInaIQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.8.tgz", + "integrity": "sha512-r2nVa5SIK9tSWd0kJd9HCffnDHKchTGikb//9c7HX+r+wHYCpQrSgxhlY6KWV1nFo1l4KFbsMlHk+L6fekLsUg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.8.tgz", + "integrity": "sha512-zUlaP2S12YhQ2UzUfcCuMDHQFJyKABkAjvO5YSndMiIkMimPmxA+BYSBikWgsRpvyxuRnow4nS5NPnf9fpv41w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.8.tgz", + "integrity": "sha512-YEGFFWESlPva8hGL+zvj2z/SaK+pH0SwOM0Nc/d+rVnW7GSTFlLBGzZkuSU9kFIGIo8q9X3ucpZhu8PDN5A2sQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.8.tgz", + "integrity": "sha512-hiGgGC6KZ5LZz58OL/+qVVoZiuZlUYlYHNAmczOm7bs2oE1XriPFi5ZHHrS8ACpV5EjySrnoCKmcbQMN+ojnHg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.8.tgz", + "integrity": "sha512-cn3Yr7+OaaZq1c+2pe+8yxC8E144SReCQjN6/2ynubzYjvyqZjTXfQJpAcQpsdJq3My7XADANiYGHoFC69pLQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "20.19.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.10.tgz", + "integrity": "sha512-iAFpG6DokED3roLSP0K+ybeDdIX6Bc0Vd3mLW5uDqThPWtNos3E+EqOM11mPQHKzfWHqEBuLjIlsBQQ8CsISmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/esbuild": { + "version": "0.25.8", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.8.tgz", + "integrity": "sha512-vVC0USHGtMi8+R4Kz8rt6JhEWLxsv9Rnu/lGYbPR8u47B+DCBksq9JarW0zOO7bs37hyOK1l2/oqtbciutL5+Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.8", + "@esbuild/android-arm": "0.25.8", + "@esbuild/android-arm64": "0.25.8", + "@esbuild/android-x64": "0.25.8", + "@esbuild/darwin-arm64": "0.25.8", + "@esbuild/darwin-x64": "0.25.8", + "@esbuild/freebsd-arm64": "0.25.8", + "@esbuild/freebsd-x64": "0.25.8", + "@esbuild/linux-arm": "0.25.8", + "@esbuild/linux-arm64": "0.25.8", + "@esbuild/linux-ia32": "0.25.8", + "@esbuild/linux-loong64": "0.25.8", + "@esbuild/linux-mips64el": "0.25.8", + "@esbuild/linux-ppc64": "0.25.8", + "@esbuild/linux-riscv64": "0.25.8", + "@esbuild/linux-s390x": "0.25.8", + "@esbuild/linux-x64": "0.25.8", + "@esbuild/netbsd-arm64": "0.25.8", + "@esbuild/netbsd-x64": "0.25.8", + "@esbuild/openbsd-arm64": "0.25.8", + "@esbuild/openbsd-x64": "0.25.8", + "@esbuild/openharmony-arm64": "0.25.8", + "@esbuild/sunos-x64": "0.25.8", + "@esbuild/win32-arm64": "0.25.8", + "@esbuild/win32-ia32": "0.25.8", + "@esbuild/win32-x64": "0.25.8" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", + "integrity": "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/mcp-hubspot": { + "resolved": "..", + "link": true + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/tsx": { + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.3.tgz", + "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/examples/package.json b/examples/package.json new file mode 100644 index 0000000..3b6486d --- /dev/null +++ b/examples/package.json @@ -0,0 +1,18 @@ +{ + "name": "mcp-hubspot-examples", + "version": "1.0.0", + "private": true, + "scripts": { + "build:parent": "cd .. && npm i && npm run build && cd -", + "build:examples": "npm i", + "build": "npm run build:parent && npm run build:examples" + }, + "devDependencies": { + "@types/node": "^20.0.0", + "dotenv": "^16.4.5", + "tsx": "^4.19.2" + }, + "dependencies": { + "mcp-hubspot": "file:.." + } +} \ No newline at end of file diff --git a/jsr.json b/jsr.json index 69cb3c6..65c224d 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "mcp-hubspot", - "version": "0.1.0", + "version": "0.2.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index ed0ca07..ac4d953 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,33 +1,34 @@ { "name": "mcp-hubspot", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "mcp-hubspot", - "version": "0.1.0", + "version": "0.2.0", + "dependencies": { + "zod": "^3.20.0" + }, "bin": { "mcp": "bin/mcp-server.js" }, "devDependencies": { "@eslint/js": "^9.19.0", - "@modelcontextprotocol/sdk": "^1.5.0", + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0", "@stricli/core": "^1.1.1", "@types/express": "^4.17.21", - "bun": "^1.2.2", - "bun-types": "^1.2.2", + "bun": "1.2.17", + "bun-types": "1.2.17", "eslint": "^9.19.0", "express": "^4.21.2", "globals": "^15.14.0", "tshy": "^2.0.0", - "typescript": "^5.4.5", - "typescript-eslint": "^8.22.0", - "zod": "^3.23.4" + "typescript": "~5.8.3", + "typescript-eslint": "^8.26.0" }, "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.5.0", - "zod": ">= 3" + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0" }, "peerDependenciesMeta": { "@modelcontextprotocol/sdk": { @@ -658,9 +659,9 @@ } }, "node_modules/@oven/bun-darwin-aarch64": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.2.5.tgz", - "integrity": "sha512-ggZfdpgUJ/OiWrfcfTgHeSTHcec5HAjkGrZHL9FJ/R60sydRKPYHgAgexdIoJAGfsCVAL+x7y8NSTRIAX8J4Ng==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.2.17.tgz", + "integrity": "sha512-66Xjz3NZXUUWKZJPvWKuwEkaqMZpir1Gm4SbhbB2iiRSSTW8jqwdkSb9RhgTCDt5OnSPd3+Cq0WsP/T5ExJbhA==", "cpu": [ "arm64" ], @@ -672,9 +673,9 @@ ] }, "node_modules/@oven/bun-darwin-x64": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.2.5.tgz", - "integrity": "sha512-4zqyQLJB33s99KcTxH6yQqH5EYBmF1qofQTtLsToIFbIZN1NqSp/aegYiGmxO5Kj/BuWsy8Wf8MS6vX2O0o2Lw==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.2.17.tgz", + "integrity": "sha512-OMJMHpcpBlWcVnWfSQ6x+8fF7HpkQLqBfoIvzxgUjIZZvj2d8K46XX4N/h62RglDEinRC9VDGxt24vwvlk5tTw==", "cpu": [ "x64" ], @@ -686,9 +687,9 @@ ] }, "node_modules/@oven/bun-darwin-x64-baseline": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.2.5.tgz", - "integrity": "sha512-3W1RO3/D6Z1S79J47F/DLzmK+dgkYq5hS1ShOCSBAYTTA2b1ZuymaN8avGzSb9ed5W0QfxtyeAksfEY2xUBOqA==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.2.17.tgz", + "integrity": "sha512-VSIctl90tV8yg1LRMvPg/8LgUzl55Q7Jcxe+u6PfuvLQIJOTIPbNn7HtRpJg7MGc3+qyztB5KDd70xC7qI2yEg==", "cpu": [ "x64" ], @@ -700,9 +701,9 @@ ] }, "node_modules/@oven/bun-linux-aarch64": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.2.5.tgz", - "integrity": "sha512-NQFtAVyQyJhLYrhFVxKdh6cqrDNc60pBnBGLQSO8PU+oyFyiJ3e3gGXjLzMbxd6cJxNIK5FZ0JIq96WljKAhlg==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.2.17.tgz", + "integrity": "sha512-KPoMqaibCXcSv+VZ3uMqKUNZqMxE6Hho1be6+laolYGOIJxJTMnZPfmKfIlQmnnW3vLlm3g2Rm8pPPC7doSHWg==", "cpu": [ "arm64" ], @@ -714,9 +715,9 @@ ] }, "node_modules/@oven/bun-linux-aarch64-musl": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.2.5.tgz", - "integrity": "sha512-URlISBOE2HQi8qdru691OYywJRwChxMfXFbk26tCgdZ01LgGAKsIjAYylefuSsPuA697imDN3Pel3D7rveusmw==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.2.17.tgz", + "integrity": "sha512-PH+hUV+I6DGD1VRHdAIAKEAOed+GSdvn6S1b3qqX27/VuHBU781V+hzt+6DBlcWBHYLw8PIg9sfIdNp485gQmw==", "cpu": [ "aarch64" ], @@ -728,9 +729,9 @@ ] }, "node_modules/@oven/bun-linux-x64": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.2.5.tgz", - "integrity": "sha512-pa3kQ4cXNV0jk5aM8+Hdmxr+b4QoPVgeAIA454SN5l3hMGfNsHjczKpsz0ksInZ8506iMMTCPEBXpyQJcSme+Q==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.2.17.tgz", + "integrity": "sha512-BfySnrTxp7D9hVUi9JEpviJl8ndsuESiRiQKTzgmdTLrMjUxP4SwrwMtYt6R9X20n9rREG6a47C0IyQMhbwG/g==", "cpu": [ "x64" ], @@ -742,9 +743,9 @@ ] }, "node_modules/@oven/bun-linux-x64-baseline": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.2.5.tgz", - "integrity": "sha512-fCm/qp7e3VYlaoRs6NIEsKubPqyxjzLv8/qZkxeLLOlPd7CS8L26UY4KPOSjA+wrhPT+Nxsyvl/EEJq2R/iauA==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.2.17.tgz", + "integrity": "sha512-IrnFMUwYWxoKICQgK8ZlJ6rI/HU2gITFNEW0MIOPIcuT0s3j0/33631M9EzYDoL4NuLQPks6569JDvSHEVqdeA==", "cpu": [ "x64" ], @@ -756,9 +757,9 @@ ] }, "node_modules/@oven/bun-linux-x64-musl": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.2.5.tgz", - "integrity": "sha512-DuU2kQnY48g9tNWjFrZqyG+U2emCBwlhOPxbuY/TMVVNSTMAcQbE/bb3s2pZdhZH5ssjc5SH/ZyWU1TePcYB2A==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.2.17.tgz", + "integrity": "sha512-fW9qn/WqO131/qSIkIPW8zN+thQnYUWa/k98EWubLG87htKSPh1v023E5ikKb7WlUv4Yb6UlE/z4NmMYKffmAg==", "cpu": [ "x64" ], @@ -770,9 +771,9 @@ ] }, "node_modules/@oven/bun-linux-x64-musl-baseline": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.2.5.tgz", - "integrity": "sha512-H7tuJz7mZvOTPo4yLbIXIxkiDGWSGd2DbwGl4zNol/FURqGsKQVqpomv86yl9KCXsUUOm5FX2i5Ed+ro8N//Cg==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.2.17.tgz", + "integrity": "sha512-YE5wQ/YA79BykMLhuwgdoF8Yjj5dRipD8dwmXs8n7gzR+/L9tL7Q69NQgskW2KkAalmWPoGAv3TV0IwbU+1dFw==", "cpu": [ "x64" ], @@ -784,9 +785,9 @@ ] }, "node_modules/@oven/bun-windows-x64": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.2.5.tgz", - "integrity": "sha512-oNDdPmzsCyvCATiYgkKWgxOeEx2F7m/i2MGUba+YJAeVXJsJg9iPJrLVBtETvKoSAgkXViwoUEw2U25jRYsp4g==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.2.17.tgz", + "integrity": "sha512-GJUg1oA59DWH6eyV8uccpgfTEVxjmgfTWQCOl2ySMXR3IfRoFwS4aQfpjcVzNmEZrv8eYt+yMuw1K7aNcWTTIg==", "cpu": [ "x64" ], @@ -798,9 +799,9 @@ ] }, "node_modules/@oven/bun-windows-x64-baseline": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.2.5.tgz", - "integrity": "sha512-j5FxI8FeKfWI6rEXA+1O3ASBMTp5CFcZ7MR+/aCpiBKrDse32wLaZMVGnvqQqs4y0YHUvR8b7eXHHTboezjL1w==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.2.17.tgz", + "integrity": "sha512-aVkq4l1yZ9VKfBOtZ2HEj0OCU5kUe3Fx6LbAG6oY6OglWVYj051i3RGaE2OdR4L4F2jDyxzfGYRTM/qs8nU5qA==", "cpu": [ "x64" ], @@ -951,16 +952,6 @@ "@types/send": "*" } }, - "node_modules/@types/ws": { - "version": "8.5.14", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.14.tgz", - "integrity": "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.27.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.27.0.tgz", @@ -1381,9 +1372,9 @@ } }, "node_modules/bun": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/bun/-/bun-1.2.5.tgz", - "integrity": "sha512-fbQLt+DPiGUrPKdmsHRRT7cQAlfjdxPVFvLZrsUPmKiTdv+pU50ypdx9yRJluknSbyaZchFVV7Lx2KXikXKX2Q==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/bun/-/bun-1.2.17.tgz", + "integrity": "sha512-lrUZTWS24eVy6v+Eph8VTwqFPcG7/XQ0rLBQEMNoQs2Vd7ctVdMGAzJKKGZRUQH+rgkD8rBeHGIVoWxX4vJLCA==", "cpu": [ "arm64", "x64", @@ -1399,31 +1390,30 @@ ], "bin": { "bun": "bin/bun.exe", - "bunx": "bin/bun.exe" + "bunx": "bin/bunx.exe" }, "optionalDependencies": { - "@oven/bun-darwin-aarch64": "1.2.5", - "@oven/bun-darwin-x64": "1.2.5", - "@oven/bun-darwin-x64-baseline": "1.2.5", - "@oven/bun-linux-aarch64": "1.2.5", - "@oven/bun-linux-aarch64-musl": "1.2.5", - "@oven/bun-linux-x64": "1.2.5", - "@oven/bun-linux-x64-baseline": "1.2.5", - "@oven/bun-linux-x64-musl": "1.2.5", - "@oven/bun-linux-x64-musl-baseline": "1.2.5", - "@oven/bun-windows-x64": "1.2.5", - "@oven/bun-windows-x64-baseline": "1.2.5" + "@oven/bun-darwin-aarch64": "1.2.17", + "@oven/bun-darwin-x64": "1.2.17", + "@oven/bun-darwin-x64-baseline": "1.2.17", + "@oven/bun-linux-aarch64": "1.2.17", + "@oven/bun-linux-aarch64-musl": "1.2.17", + "@oven/bun-linux-x64": "1.2.17", + "@oven/bun-linux-x64-baseline": "1.2.17", + "@oven/bun-linux-x64-musl": "1.2.17", + "@oven/bun-linux-x64-musl-baseline": "1.2.17", + "@oven/bun-windows-x64": "1.2.17", + "@oven/bun-windows-x64-baseline": "1.2.17" } }, "node_modules/bun-types": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.2.5.tgz", - "integrity": "sha512-3oO6LVGGRRKI4kHINx5PIdIgnLRb7l/SprhzqXapmoYkFl5m4j6EvALvbDVuuBFaamB46Ap6HCUxIXNLCGy+tg==", + "version": "1.2.17", + "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.2.17.tgz", + "integrity": "sha512-ElC7ItwT3SCQwYZDYoAH+q6KT4Fxjl8DtZ6qDulUFBmXA8YB4xo+l54J9ZJN+k2pphfn9vk7kfubeSd5QfTVJQ==", "dev": true, "license": "MIT", "dependencies": { - "@types/node": "*", - "@types/ws": "~8.5.10" + "@types/node": "*" } }, "node_modules/bytes": { @@ -3814,9 +3804,9 @@ } }, "node_modules/typescript": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", - "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -4049,7 +4039,6 @@ "version": "3.24.2", "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index 8006f37..793c04c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcp-hubspot", - "version": "0.1.0", + "version": "0.2.0", "author": "speakeasyapi", "type": "module", "bin": { @@ -33,8 +33,7 @@ "prepublishOnly": "npm run build" }, "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.5.0", - "zod": ">= 3" + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0" }, "peerDependenciesMeta": { "@modelcontextprotocol/sdk": { @@ -43,20 +42,21 @@ }, "devDependencies": { "@eslint/js": "^9.19.0", - "@modelcontextprotocol/sdk": "^1.5.0", + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0", "@stricli/core": "^1.1.1", "@types/express": "^4.17.21", - "bun": "^1.2.2", - "bun-types": "^1.2.2", + "bun": "1.2.17", + "bun-types": "1.2.17", "eslint": "^9.19.0", "express": "^4.21.2", "globals": "^15.14.0", "tshy": "^2.0.0", - "typescript": "^5.4.5", - "typescript-eslint": "^8.22.0", - "zod": "^3.23.4" + "typescript": "~5.8.3", + "typescript-eslint": "^8.26.0" + }, + "dependencies": { + "zod": "^3.20.0" }, - "dependencies": {}, "exports": { ".": { "import": { diff --git a/src/funcs/basicCreateContact.ts b/src/funcs/basicCreateContact.ts index 99c0788..7bd2882 100644 --- a/src/funcs/basicCreateContact.ts +++ b/src/funcs/basicCreateContact.ts @@ -11,7 +11,6 @@ import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -19,6 +18,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -42,13 +43,14 @@ export function basicCreateContact( ): APIPromise< Result< operations.CreateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -66,13 +68,14 @@ async function $do( [ Result< operations.CreateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -101,6 +104,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "createContact", oAuth2Scopes: [], @@ -121,6 +125,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -141,13 +146,14 @@ async function $do( const [result] = await M.match< operations.CreateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(201, operations.CreateContactResponse$inboundSchema), M.fail("4XX"), @@ -155,7 +161,7 @@ async function $do( M.bytes("default", operations.CreateContactResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicCreateDeal.ts b/src/funcs/basicCreateDeal.ts index d5771ea..3f865d0 100644 --- a/src/funcs/basicCreateDeal.ts +++ b/src/funcs/basicCreateDeal.ts @@ -11,7 +11,6 @@ import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -19,6 +18,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -42,13 +43,14 @@ export function basicCreateDeal( ): APIPromise< Result< operations.CreateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -66,13 +68,14 @@ async function $do( [ Result< operations.CreateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -101,6 +104,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "createDeal", oAuth2Scopes: [], @@ -121,6 +125,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -141,13 +146,14 @@ async function $do( const [result] = await M.match< operations.CreateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(201, operations.CreateDealResponse$inboundSchema), M.fail("4XX"), @@ -155,7 +161,7 @@ async function $do( M.bytes("default", operations.CreateDealResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicGetCompany.ts b/src/funcs/basicGetCompany.ts index bf43d16..8aa9106 100644 --- a/src/funcs/basicGetCompany.ts +++ b/src/funcs/basicGetCompany.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicGetCompany( ): APIPromise< Result< operations.GetCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.GetCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -113,6 +116,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "getCompany", oAuth2Scopes: [], @@ -134,6 +138,7 @@ async function $do( headers: headers, query: query, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -154,13 +159,14 @@ async function $do( const [result] = await M.match< operations.GetCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.GetCompanyResponse$inboundSchema), M.fail("4XX"), @@ -168,7 +174,7 @@ async function $do( M.bytes("default", operations.GetCompanyResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicGetContact.ts b/src/funcs/basicGetContact.ts index 3953627..0ae756b 100644 --- a/src/funcs/basicGetContact.ts +++ b/src/funcs/basicGetContact.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicGetContact( ): APIPromise< Result< operations.GetContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.GetContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -112,6 +115,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "getContact", oAuth2Scopes: [], @@ -133,6 +137,7 @@ async function $do( headers: headers, query: query, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -153,13 +158,14 @@ async function $do( const [result] = await M.match< operations.GetContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.GetContactResponse$inboundSchema), M.fail("4XX"), @@ -167,7 +173,7 @@ async function $do( M.bytes("default", operations.GetContactResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicGetDeal.ts b/src/funcs/basicGetDeal.ts index 9796c26..a959349 100644 --- a/src/funcs/basicGetDeal.ts +++ b/src/funcs/basicGetDeal.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicGetDeal( ): APIPromise< Result< operations.GetDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.GetDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -113,6 +116,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "getDeal", oAuth2Scopes: [], @@ -134,6 +138,7 @@ async function $do( headers: headers, query: query, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -154,13 +159,14 @@ async function $do( const [result] = await M.match< operations.GetDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.GetDealResponse$inboundSchema), M.fail("4XX"), @@ -168,7 +174,7 @@ async function $do( M.bytes("default", operations.GetDealResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicGetProperties.ts b/src/funcs/basicGetProperties.ts index 75b539c..cdea3fe 100644 --- a/src/funcs/basicGetProperties.ts +++ b/src/funcs/basicGetProperties.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicGetProperties( ): APIPromise< Result< operations.GetPropertiesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.GetPropertiesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -105,6 +108,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "getProperties", oAuth2Scopes: [], @@ -125,6 +129,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -145,13 +150,14 @@ async function $do( const [result] = await M.match< operations.GetPropertiesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.GetPropertiesResponse$inboundSchema), M.fail("4XX"), @@ -159,7 +165,7 @@ async function $do( M.bytes("default", operations.GetPropertiesResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicUpdateCompany.ts b/src/funcs/basicUpdateCompany.ts index a9c1adf..244d445 100644 --- a/src/funcs/basicUpdateCompany.ts +++ b/src/funcs/basicUpdateCompany.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicUpdateCompany( ): APIPromise< Result< operations.UpdateCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.UpdateCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -112,6 +115,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "updateCompany", oAuth2Scopes: [], @@ -133,6 +137,7 @@ async function $do( headers: headers, query: query, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -153,13 +158,14 @@ async function $do( const [result] = await M.match< operations.UpdateCompanyResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.UpdateCompanyResponse$inboundSchema), M.fail("4XX"), @@ -167,7 +173,7 @@ async function $do( M.bytes("default", operations.UpdateCompanyResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicUpdateContact.ts b/src/funcs/basicUpdateContact.ts index cecc217..2543e35 100644 --- a/src/funcs/basicUpdateContact.ts +++ b/src/funcs/basicUpdateContact.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicUpdateContact( ): APIPromise< Result< operations.UpdateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.UpdateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -108,6 +111,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "updateContact", oAuth2Scopes: [], @@ -128,6 +132,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -148,13 +153,14 @@ async function $do( const [result] = await M.match< operations.UpdateContactResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.UpdateContactResponse$inboundSchema), M.fail("4XX"), @@ -162,7 +168,7 @@ async function $do( M.bytes("default", operations.UpdateContactResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/basicUpdateDeal.ts b/src/funcs/basicUpdateDeal.ts index 4fd922a..80992ee 100644 --- a/src/funcs/basicUpdateDeal.ts +++ b/src/funcs/basicUpdateDeal.ts @@ -10,7 +10,6 @@ import { safeParse } from "../lib/schemas.js"; import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -18,6 +17,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -41,13 +42,14 @@ export function basicUpdateDeal( ): APIPromise< Result< operations.UpdateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -65,13 +67,14 @@ async function $do( [ Result< operations.UpdateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -112,6 +115,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "updateDeal", oAuth2Scopes: [], @@ -133,6 +137,7 @@ async function $do( headers: headers, query: query, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -153,13 +158,14 @@ async function $do( const [result] = await M.match< operations.UpdateDealResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.UpdateDealResponse$inboundSchema), M.fail("4XX"), @@ -167,7 +173,7 @@ async function $do( M.bytes("default", operations.UpdateDealResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/searchSearchCompanies.ts b/src/funcs/searchSearchCompanies.ts index cd0be6a..4f97840 100644 --- a/src/funcs/searchSearchCompanies.ts +++ b/src/funcs/searchSearchCompanies.ts @@ -11,7 +11,6 @@ import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -19,6 +18,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -44,13 +45,14 @@ export function searchSearchCompanies( ): APIPromise< Result< operations.SearchCompaniesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -70,13 +72,14 @@ async function $do( [ Result< operations.SearchCompaniesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -104,6 +107,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "searchCompanies", oAuth2Scopes: [], @@ -124,6 +128,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -144,13 +149,14 @@ async function $do( const [result] = await M.match< operations.SearchCompaniesResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.SearchCompaniesResponse$inboundSchema), M.fail("4XX"), @@ -158,7 +164,7 @@ async function $do( M.bytes("default", operations.SearchCompaniesResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/searchSearchContacts.ts b/src/funcs/searchSearchContacts.ts index cb848b7..cf5fbae 100644 --- a/src/funcs/searchSearchContacts.ts +++ b/src/funcs/searchSearchContacts.ts @@ -11,7 +11,6 @@ import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -19,6 +18,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -44,13 +45,14 @@ export function searchSearchContacts( ): APIPromise< Result< operations.SearchContactsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -70,13 +72,14 @@ async function $do( [ Result< operations.SearchContactsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -104,6 +107,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "searchContacts", oAuth2Scopes: [], @@ -124,6 +128,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -144,13 +149,14 @@ async function $do( const [result] = await M.match< operations.SearchContactsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.SearchContactsResponse$inboundSchema), M.fail("4XX"), @@ -158,7 +164,7 @@ async function $do( M.bytes("default", operations.SearchContactsResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/searchSearchDeals.ts b/src/funcs/searchSearchDeals.ts index 65581c2..1031ef6 100644 --- a/src/funcs/searchSearchDeals.ts +++ b/src/funcs/searchSearchDeals.ts @@ -11,7 +11,6 @@ import { RequestOptions } from "../lib/sdks.js"; import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; import { pathToFunc } from "../lib/url.js"; import * as components from "../models/components/index.js"; -import { APIError } from "../models/errors/apierror.js"; import { ConnectionError, InvalidRequestError, @@ -19,6 +18,8 @@ import { RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; +import { HubspotError } from "../models/errors/hubspoterror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { APICall, APIPromise } from "../types/async.js"; @@ -36,13 +37,14 @@ export function searchSearchDeals( ): APIPromise< Result< operations.SearchDealsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError > > { return new APIPromise($do( @@ -60,13 +62,14 @@ async function $do( [ Result< operations.SearchDealsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >, APICall, ] @@ -94,6 +97,7 @@ async function $do( const requestSecurity = resolveGlobalSecurity(securityInput); const context = { + options: client._options, baseURL: options?.serverURL ?? client._baseURL ?? "", operationID: "searchDeals", oAuth2Scopes: [], @@ -114,6 +118,7 @@ async function $do( path: path, headers: headers, body: body, + userAgent: client._options.userAgent, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { @@ -134,13 +139,14 @@ async function $do( const [result] = await M.match< operations.SearchDealsResponse, - | APIError - | SDKValidationError - | UnexpectedClientError - | InvalidRequestError + | HubspotError + | ResponseValidationError + | ConnectionError | RequestAbortedError | RequestTimeoutError - | ConnectionError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError >( M.json(200, operations.SearchDealsResponse$inboundSchema), M.fail("4XX"), @@ -148,7 +154,7 @@ async function $do( M.bytes("default", operations.SearchDealsResponse$inboundSchema, { ctype: "*/*", }), - )(response); + )(response, req); if (!result.ok) { return [result, { status: "complete", request: req, response }]; } diff --git a/src/hooks/types.ts b/src/hooks/types.ts index f34898c..8bfe4fe 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -2,6 +2,7 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +import { SDKOptions } from "../lib/config.js"; import { HTTPClient, RequestInput } from "../lib/http.js"; import { RetryConfig } from "../lib/retries.js"; import { SecurityState } from "../lib/security.js"; @@ -9,10 +10,11 @@ import { SecurityState } from "../lib/security.js"; export type HookContext = { baseURL: string | URL; operationID: string; - oAuth2Scopes?: string[]; + oAuth2Scopes: string[] | null; securitySource?: any | (() => Promise); retryConfig: RetryConfig; resolvedSecurity: SecurityState | null; + options: SDKOptions; }; export type Awaitable = T | Promise; diff --git a/src/index.ts b/src/index.ts index 5ddc765..dbcba16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,4 +4,6 @@ export * from "./lib/config.js"; export * as files from "./lib/files.js"; +export { HTTPClient } from "./lib/http.js"; +export type { Fetcher, HTTPClientOptions } from "./lib/http.js"; export * from "./sdk/sdk.js"; diff --git a/src/lib/config.ts b/src/lib/config.ts index a65a933..23ef08f 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -26,6 +26,10 @@ export type SDKOptions = { * Allows overriding the default server URL used by the SDK */ serverURL?: string | undefined; + /** + * Allows overriding the default user agent used by the SDK + */ + userAgent?: string | undefined; /** * Allows overriding the default retry config used by the SDK */ @@ -54,7 +58,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "v3", - sdkVersion: "0.1.0", - genVersion: "2.558.5", - userAgent: "speakeasy-sdk/typescript 0.1.0 2.558.5 v3 mcp-hubspot", + sdkVersion: "0.2.0", + genVersion: "2.677.3", + userAgent: "speakeasy-sdk/typescript 0.2.0 2.677.3 v3 mcp-hubspot", } as const; diff --git a/src/lib/files.ts b/src/lib/files.ts index 59d15f0..0344cd0 100644 --- a/src/lib/files.ts +++ b/src/lib/files.ts @@ -38,3 +38,45 @@ export async function readableStreamToArrayBuffer( return concatenatedChunks.buffer as ArrayBuffer; } + +/** + * Determines the MIME content type based on a file's extension. + * Returns null if the extension is not recognized. + */ +export function getContentTypeFromFileName(fileName: string): string | null { + if (!fileName) return null; + + const ext = fileName.toLowerCase().split(".").pop(); + if (!ext) return null; + + const mimeTypes: Record = { + json: "application/json", + xml: "application/xml", + html: "text/html", + htm: "text/html", + txt: "text/plain", + csv: "text/csv", + pdf: "application/pdf", + png: "image/png", + jpg: "image/jpeg", + jpeg: "image/jpeg", + gif: "image/gif", + svg: "image/svg+xml", + js: "application/javascript", + css: "text/css", + zip: "application/zip", + tar: "application/x-tar", + gz: "application/gzip", + mp4: "video/mp4", + mp3: "audio/mpeg", + wav: "audio/wav", + webp: "image/webp", + ico: "image/x-icon", + woff: "font/woff", + woff2: "font/woff2", + ttf: "font/ttf", + otf: "font/otf", + }; + + return mimeTypes[ext] || null; +} diff --git a/src/lib/matchers.ts b/src/lib/matchers.ts index 65858ac..77d4108 100644 --- a/src/lib/matchers.ts +++ b/src/lib/matchers.ts @@ -3,13 +3,13 @@ */ import { APIError } from "../models/errors/apierror.js"; -import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; -import { Result } from "../types/fp.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { ERR, OK, Result } from "../types/fp.js"; import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js"; import { isPlainObject } from "./is-plain-object.js"; -import { safeParse } from "./schemas.js"; export type Encoding = + | "jsonl" | "json" | "text" | "bytes" @@ -19,6 +19,7 @@ export type Encoding = | "fail"; const DEFAULT_CONTENT_TYPES: Record = { + jsonl: "application/jsonl", json: "application/json", text: "text/plain", bytes: "application/octet-stream", @@ -72,6 +73,21 @@ export function json( return { ...options, enc: "json", codes, schema }; } +export function jsonl( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ValueMatcher { + return { ...options, enc: "jsonl", codes, schema }; +} + +export function jsonlErr( + codes: StatusCodePredicate, + schema: Schema, + options?: MatchOptions, +): ErrorMatcher { + return { ...options, err: true, enc: "jsonl", codes, schema }; +} export function textErr( codes: StatusCodePredicate, schema: Schema, @@ -159,17 +175,19 @@ export type MatchedError = Matchers extends Matcher[] : never; export type MatchFunc = ( response: Response, + request: Request, options?: { resultKey?: string; extraFields?: Record }, ) => Promise<[result: Result, raw: unknown]>; export function match( ...matchers: Array> -): MatchFunc { +): MatchFunc { return async function matchFunc( response: Response, + request: Request, options?: { resultKey?: string; extraFields?: Record }, ): Promise< - [result: Result, raw: unknown] + [result: Result, raw: unknown] > { let raw: unknown; let matcher: Matcher | undefined; @@ -188,21 +206,25 @@ export function match( } if (!matcher) { - const responseBody = await response.text(); return [{ ok: false, - error: new APIError( - "Unexpected API response status or content-type", + error: new APIError("Unexpected Status or Content-Type", { response, - responseBody, - ), - }, responseBody]; + request, + body: await response.text().catch(() => ""), + }), + }, raw]; } const encoding = matcher.enc; + let body = ""; switch (encoding) { case "json": - raw = await response.json(); + body = await response.text(); + raw = JSON.parse(body); + break; + case "jsonl": + raw = response.body; break; case "bytes": raw = new Uint8Array(await response.arrayBuffer()); @@ -211,16 +233,19 @@ export function match( raw = response.body; break; case "text": - raw = await response.text(); + body = await response.text(); + raw = body; break; case "sse": raw = response.body; break; case "nil": - raw = await discardResponseBody(response); + body = await response.text(); + raw = undefined; break; case "fail": - raw = await response.text(); + body = await response.text(); + raw = body; break; default: encoding satisfies never; @@ -230,11 +255,7 @@ export function match( if (matcher.enc === "fail") { return [{ ok: false, - error: new APIError( - "API error occurred", - response, - typeof raw === "string" ? raw : "", - ), + error: new APIError("API error occurred", { request, response, body }), }, raw]; } @@ -246,6 +267,9 @@ export function match( ...options?.extraFields, ...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null), ...(isPlainObject(raw) ? raw : null), + request$: request, + response$: response, + body$: body, }; } else if (resultKey) { data = { @@ -264,18 +288,20 @@ export function match( } if ("err" in matcher) { - const result = safeParse( + const result = safeParseResponse( data, (v: unknown) => matcher.schema.parse(v), "Response validation failed", + { request, response, body }, ); return [result.ok ? { ok: false, error: result.value } : result, raw]; } else { return [ - safeParse( + safeParseResponse( data, (v: unknown) => matcher.schema.parse(v), "Response validation failed", + { request, response, body }, ), raw, ]; @@ -298,25 +324,22 @@ export function unpackHeaders(headers: Headers): Record { return out; } -/** - * Discards the response body to free up resources. - * - * To learn why this is need, see the undici docs: - * https://undici.nodejs.org/#/?id=garbage-collection - */ -export async function discardResponseBody(res: Response) { - const reader = res.body?.getReader(); - if (reader == null) { - return; - } - +function safeParseResponse( + rawValue: Inp, + fn: (value: Inp) => Out, + errorMessage: string, + httpMeta: { response: Response; request: Request; body: string }, +): Result { try { - let done = false; - while (!done) { - const res = await reader.read(); - done = res.done; - } - } finally { - reader.releaseLock(); + return OK(fn(rawValue)); + } catch (err) { + return ERR( + new ResponseValidationError(errorMessage, { + cause: err, + rawValue, + rawMessage: errorMessage, + ...httpMeta, + }), + ); } } diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index 7812805..03b9ce0 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -47,12 +47,14 @@ export type RequestOptions = { */ serverURL?: string | URL; /** + * @deprecated `fetchOptions` has been flattened into `RequestOptions`. + * * Sets various request options on the `fetch` call made by an SDK method. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options|Request} */ fetchOptions?: Omit; -}; +} & Omit; type RequestConfig = { method: string; @@ -63,6 +65,7 @@ type RequestConfig = { headers?: HeadersInit; security?: SecurityState | null; uaHeader?: string; + userAgent?: string | undefined; timeoutMs?: number; }; @@ -94,19 +97,21 @@ export class ClientSDK { } else { this.#hooks = new SDKHooks(); } - this._options = { ...options, hooks: this.#hooks }; - const url = serverURLFromOptions(options); if (url) { url.pathname = url.pathname.replace(/\/+$/, "") + "/"; } + const { baseURL, client } = this.#hooks.sdkInit({ baseURL: url, client: options.httpClient || new HTTPClient(), }); this._baseURL = baseURL; this.#httpClient = client; - this.#logger = options.debugLogger; + + this._options = { ...options, hooks: this.#hooks }; + + this.#logger = this._options.debugLogger; if (!this.#logger && env().HUBSPOT_DEBUG) { this.#logger = console; } @@ -172,7 +177,9 @@ export class ClientSDK { cookie = cookie.startsWith("; ") ? cookie.slice(2) : cookie; headers.set("cookie", cookie); - const userHeaders = new Headers(options?.fetchOptions?.headers); + const userHeaders = new Headers( + options?.headers ?? options?.fetchOptions?.headers, + ); for (const [k, v] of userHeaders) { headers.set(k, v); } @@ -180,23 +187,22 @@ export class ClientSDK { // Only set user agent header in non-browser-like environments since CORS // policy disallows setting it in browsers e.g. Chrome throws an error. if (!isBrowserLike) { - headers.set(conf.uaHeader ?? "user-agent", SDK_METADATA.userAgent); + headers.set( + conf.uaHeader ?? "user-agent", + conf.userAgent ?? SDK_METADATA.userAgent, + ); } - let fetchOptions = options?.fetchOptions; + const fetchOptions: Omit = { + ...options?.fetchOptions, + ...options, + }; if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) { const timeoutSignal = AbortSignal.timeout(conf.timeoutMs); - if (!fetchOptions) { - fetchOptions = { signal: timeoutSignal }; - } else { - fetchOptions.signal = timeoutSignal; - } + fetchOptions.signal = timeoutSignal; } if (conf.body instanceof ReadableStream) { - if (!fetchOptions) { - fetchOptions = {}; - } Object.assign(fetchOptions, { duplex: "half" }); } @@ -302,7 +308,9 @@ export class ClientSDK { } } -const jsonLikeContentTypeRE = /^application\/(?:.{0,100}\+)?json/; +const jsonLikeContentTypeRE = /(application|text)\/.*?\+*json.*/; +const jsonlLikeContentTypeRE = + /(application|text)\/(.*?\+*\bjsonl\b.*|.*?\+*\bx-ndjson\b.*)/; async function logRequest(logger: Logger | undefined, req: Request) { if (!logger) { return; @@ -368,9 +376,13 @@ async function logResponse( logger.group("Body:"); switch (true) { case matchContentType(res, "application/json") - || jsonLikeContentTypeRE.test(ct): + || jsonLikeContentTypeRE.test(ct) && !jsonlLikeContentTypeRE.test(ct): logger.log(await res.clone().json()); break; + case matchContentType(res, "application/jsonl") + || jsonlLikeContentTypeRE.test(ct): + logger.log(await res.clone().text()); + break; case matchContentType(res, "text/event-stream"): logger.log(`<${contentType}>`); break; diff --git a/src/lib/security.ts b/src/lib/security.ts index c986051..de465bc 100644 --- a/src/lib/security.ts +++ b/src/lib/security.ts @@ -7,8 +7,8 @@ import { env } from "./env.js"; type OAuth2PasswordFlow = { username: string; - password?: string | undefined; - clientID: string; + password: string; + clientID?: string | undefined; clientSecret?: string | undefined; tokenURL: string; }; diff --git a/src/mcp-server/cli/start/command.ts b/src/mcp-server/cli/start/command.ts index c5f4595..9947028 100644 --- a/src/mcp-server/cli/start/command.ts +++ b/src/mcp-server/cli/start/command.ts @@ -37,18 +37,13 @@ export const startCommand = buildCommand({ return z.string().parse(value); }, }, - ...(mcpScopes.length - ? { - scope: { - kind: "enum", - brief: - "Mount tools/resources that match given scope (repeatable flag)", - values: mcpScopes, - variadic: true, - optional: true, - }, - } - : {}), + scope: { + kind: "enum", + brief: "Mount tools/resources that match given scope (repeatable flag)", + values: mcpScopes, + variadic: true, + optional: true, + }, "hubspot-token": { kind: "parsed", brief: "Sets the hubspotToken auth field for the API", diff --git a/src/mcp-server/cli/start/impl.ts b/src/mcp-server/cli/start/impl.ts index 0cbef8e..593f8f7 100644 --- a/src/mcp-server/cli/start/impl.ts +++ b/src/mcp-server/cli/start/impl.ts @@ -50,7 +50,7 @@ async function startStdio(flags: StartCommandFlags) { logger, allowedTools: flags.tool, scopes: flags.scope, - ...{ hubspotToken: flags["hubspot-token"] }, + ...{ hubspotToken: flags["hubspot-token"] ?? "" }, serverURL: flags["server-url"], serverIdx: flags["server-index"], }); @@ -71,7 +71,7 @@ async function startSSE(flags: StartCommandFlags) { logger, allowedTools: flags.tool, scopes: flags.scope, - ...{ hubspotToken: flags["hubspot-token"] }, + ...{ hubspotToken: flags["hubspot-token"] ?? "" }, serverURL: flags["server-url"], serverIdx: flags["server-index"], }); diff --git a/src/mcp-server/mcp-server.ts b/src/mcp-server/mcp-server.ts index 549dc47..d643b83 100644 --- a/src/mcp-server/mcp-server.ts +++ b/src/mcp-server/mcp-server.ts @@ -19,7 +19,7 @@ const routes = buildRouteMap({ export const app = buildApplication(routes, { name: "mcp", versionInfo: { - currentVersion: "0.1.0", + currentVersion: "0.2.0", }, }); diff --git a/src/mcp-server/prompts.ts b/src/mcp-server/prompts.ts index 48080de..5696e3a 100644 --- a/src/mcp-server/prompts.ts +++ b/src/mcp-server/prompts.ts @@ -74,7 +74,14 @@ export function createRegisterPrompt( prompt: PromptDefinition, ): void => { const scopes = prompt.scopes ?? []; - if (!scopes.every((s: MCPScope) => allowedScopes.has(s))) { + if (allowedScopes.size > 0 && scopes.length === 0) { + return; + } + + if ( + allowedScopes.size > 0 + && !scopes.every((s: MCPScope) => allowedScopes.has(s)) + ) { return; } diff --git a/src/mcp-server/resources.ts b/src/mcp-server/resources.ts index 70ea028..c433843 100644 --- a/src/mcp-server/resources.ts +++ b/src/mcp-server/resources.ts @@ -109,7 +109,14 @@ export function createRegisterResource( ): (resource: ResourceDefinition) => void { return (resource: ResourceDefinition): void => { const scopes = resource.scopes ?? []; - if (!scopes.every((s: MCPScope) => allowedScopes.has(s))) { + if (allowedScopes.size > 0 && scopes.length === 0) { + return; + } + + if ( + allowedScopes.size > 0 + && !scopes.every((s: MCPScope) => allowedScopes.has(s)) + ) { return; } @@ -137,7 +144,14 @@ export function createRegisterResourceTemplate( ): (resource: ResourceTemplateDefinition) => void { return (resource: ResourceTemplateDefinition): void => { const scopes = resource.scopes ?? []; - if (!scopes.every((s: MCPScope) => allowedScopes.has(s))) { + if (allowedScopes.size > 0 && scopes.length === 0) { + return; + } + + if ( + allowedScopes.size > 0 + && !scopes.every((s: MCPScope) => allowedScopes.has(s)) + ) { return; } diff --git a/src/mcp-server/server.ts b/src/mcp-server/server.ts index 0d51f98..e7fa68e 100644 --- a/src/mcp-server/server.ts +++ b/src/mcp-server/server.ts @@ -6,12 +6,14 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { HubspotCore } from "../core.js"; import { SDKOptions } from "../lib/config.js"; import type { ConsoleLogger } from "./console-logger.js"; +import { Register } from "./extensions.js"; import { createRegisterPrompt } from "./prompts.js"; import { createRegisterResource, createRegisterResourceTemplate, } from "./resources.js"; -import { MCPScope, mcpScopes } from "./scopes.js"; +import { MCPScope } from "./scopes.js"; +import { registerMCPExtensions } from "./server.extensions.js"; import { createRegisterTool } from "./tools.js"; import { tool$basicCreateContact } from "./tools/basicCreateContact.js"; import { tool$basicCreateDeal } from "./tools/basicCreateDeal.js"; @@ -36,7 +38,7 @@ export function createMCPServer(deps: { }) { const server = new McpServer({ name: "Hubspot", - version: "0.1.0", + version: "0.2.0", }); const client = new HubspotCore({ @@ -45,7 +47,7 @@ export function createMCPServer(deps: { serverIdx: deps.serverIdx, }); - const scopes = new Set(deps.scopes ?? mcpScopes); + const scopes = new Set(deps.scopes); const allowedTools = deps.allowedTools && new Set(deps.allowedTools); const tool = createRegisterTool( @@ -79,5 +81,7 @@ export function createMCPServer(deps: { tool(tool$searchSearchContacts); tool(tool$searchSearchDeals); + registerMCPExtensions(register satisfies Register); + return server; } diff --git a/src/mcp-server/tools.ts b/src/mcp-server/tools.ts index 690f648..91bcb29 100644 --- a/src/mcp-server/tools.ts +++ b/src/mcp-server/tools.ts @@ -102,12 +102,15 @@ export function createRegisterTool( return; } - const toolScopes = tool.scopes ?? []; - if (allowedScopes.size > 0 && toolScopes.length === 0) { + const scopes = tool.scopes ?? []; + if (allowedScopes.size > 0 && scopes.length === 0) { return; } - if (!toolScopes.every((s) => allowedScopes.has(s))) { + if ( + allowedScopes.size > 0 + && !scopes.every((s: MCPScope) => allowedScopes.has(s)) + ) { return; } diff --git a/src/models/errors/apierror.ts b/src/models/errors/apierror.ts index 3a04a1c..1f4684c 100644 --- a/src/models/errors/apierror.ts +++ b/src/models/errors/apierror.ts @@ -2,26 +2,39 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ -export class APIError extends Error { - public readonly statusCode: number; - public readonly contentType: string; +import { HubspotError } from "./hubspoterror.js"; +/** The fallback error class if no more specific error class is matched */ +export class APIError extends HubspotError { constructor( message: string, - public readonly rawResponse: Response, - public readonly body: string = "", + httpMeta: { + response: Response; + request: Request; + body: string; + }, ) { - const statusCode = rawResponse.status; - const contentType = rawResponse.headers.get("content-type") || ""; - const bodyString = body.length > 0 ? `\n${body}` : ""; - - super( - `${message}: Status ${statusCode} Content-Type ${contentType} Body ${bodyString}`, - ); - - this.statusCode = statusCode; - this.contentType = contentType; - + if (message) { + message += `: `; + } + message += `Status ${httpMeta.response.status}`; + const contentType = httpMeta.response.headers.get("content-type") || `""`; + if (contentType !== "application/json") { + message += ` Content-Type ${ + contentType.includes(" ") ? `"${contentType}"` : contentType + }`; + } + const body = httpMeta.body || `""`; + message += body.length > 100 ? "\n" : ". "; + let bodyDisplay = body; + if (body.length > 10000) { + const truncated = body.substring(0, 10000); + const remaining = body.length - 10000; + bodyDisplay = `${truncated}...and ${remaining} more chars`; + } + message += `Body: ${bodyDisplay}`; + message = message.trim(); + super(message, httpMeta); this.name = "APIError"; } } diff --git a/src/models/errors/hubspoterror.ts b/src/models/errors/hubspoterror.ts new file mode 100644 index 0000000..93eb3b3 --- /dev/null +++ b/src/models/errors/hubspoterror.ts @@ -0,0 +1,35 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +/** The base class for all HTTP error responses */ +export class HubspotError extends Error { + /** HTTP status code */ + public readonly statusCode: number; + /** HTTP body */ + public readonly body: string; + /** HTTP headers */ + public readonly headers: Headers; + /** HTTP content type */ + public readonly contentType: string; + /** Raw response */ + public readonly rawResponse: Response; + + constructor( + message: string, + httpMeta: { + response: Response; + request: Request; + body: string; + }, + ) { + super(message); + this.statusCode = httpMeta.response.status; + this.body = httpMeta.body; + this.headers = httpMeta.response.headers; + this.contentType = httpMeta.response.headers.get("content-type") || ""; + this.rawResponse = httpMeta.response; + + this.name = "HubspotError"; + } +} diff --git a/src/models/errors/index.ts b/src/models/errors/index.ts index 7b2a3be..8fae157 100644 --- a/src/models/errors/index.ts +++ b/src/models/errors/index.ts @@ -4,4 +4,5 @@ export * from "./apierror.js"; export * from "./httpclienterrors.js"; +export * from "./responsevalidationerror.js"; export * from "./sdkvalidationerror.js"; diff --git a/src/models/errors/responsevalidationerror.ts b/src/models/errors/responsevalidationerror.ts new file mode 100644 index 0000000..cb6f522 --- /dev/null +++ b/src/models/errors/responsevalidationerror.ts @@ -0,0 +1,50 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { HubspotError } from "./hubspoterror.js"; +import { formatZodError } from "./sdkvalidationerror.js"; + +export class ResponseValidationError extends HubspotError { + /** + * The raw value that failed validation. + */ + public readonly rawValue: unknown; + + /** + * The raw message that failed validation. + */ + public readonly rawMessage: unknown; + + constructor( + message: string, + extra: { + response: Response; + request: Request; + body: string; + cause: unknown; + rawValue: unknown; + rawMessage: unknown; + }, + ) { + super(message, extra); + this.name = "ResponseValidationError"; + this.cause = extra.cause; + this.rawValue = extra.rawValue; + this.rawMessage = extra.rawMessage; + } + + /** + * Return a pretty-formatted error message if the underlying validation error + * is a ZodError or some other recognized error type, otherwise return the + * default error message. + */ + public pretty(): string { + if (this.cause instanceof z.ZodError) { + return `${this.rawMessage}\n${formatZodError(this.cause)}`; + } else { + return this.toString(); + } + } +} diff --git a/src/models/errors/sdkvalidationerror.ts b/src/models/errors/sdkvalidationerror.ts index 16929b9..37face8 100644 --- a/src/models/errors/sdkvalidationerror.ts +++ b/src/models/errors/sdkvalidationerror.ts @@ -15,6 +15,18 @@ export class SDKValidationError extends Error { */ public readonly rawMessage: unknown; + // Allows for backwards compatibility for `instanceof` checks of `ResponseValidationError` + static override [Symbol.hasInstance]( + instance: unknown, + ): instance is SDKValidationError { + if (!(instance instanceof Error)) return false; + if (!("rawValue" in instance)) return false; + if (!("rawMessage" in instance)) return false; + if (!("pretty" in instance)) return false; + if (typeof instance.pretty !== "function") return false; + return true; + } + constructor(message: string, cause: unknown, rawValue: unknown) { super(`${message}: ${cause}`); this.name = "SDKValidationError"; diff --git a/src/types/constdatetime.ts b/src/types/constdatetime.ts index c0a4409..eeff4dd 100644 --- a/src/types/constdatetime.ts +++ b/src/types/constdatetime.ts @@ -11,5 +11,5 @@ export function constDateTime( return ( typeof v === "string" && new Date(v).getTime() === new Date(val).getTime() ); - }, `Value must be equivelant to ${val}`); + }, `Value must be equivalent to ${val}`); }