diff --git a/.gitignore b/.gitignore index 4829686..733c54e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.DS_Store /models /models/errors /types diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 00daae1..e81b7d7 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.563.1 + generationVersion: 2.629.1 + releaseVersion: 0.2.0 + configChecksum: e27698c47b0f2087f258734f0a857a2f repoURL: https://github.com/speakeasy-api/hubspot-typescript.git installationURL: https://github.com/speakeasy-api/hubspot-typescript published: true @@ -15,7 +15,7 @@ features: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 constsAndDefaults: 0.1.11 - core: 3.21.4 + core: 3.21.11 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.2 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 @@ -170,7 +170,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 +206,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 +221,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 +245,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 +278,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..4c7436c 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,17 +15,19 @@ generation: parameterOrderingFeb2024: true requestResponseComponentNamesFeb2024: true securityFeb2025: true + sharedErrorComponentsApr2025: false auth: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: true typescript: - version: 0.1.0 + version: 0.2.0 additionalDependencies: dependencies: {} devDependencies: {} peerDependencies: {} additionalPackageJSON: {} author: speakeasyapi + baseErrorName: HubspotError clientServerStatusCodesAsErrors: true defaultErrorName: APIError enableCustomCodeRegions: false diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index a2da036..37f8c3c 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.521.1 +speakeasyVersion: 1.563.1 sources: CRM: sourceNamespace: crm @@ -9,20 +9,20 @@ sources: - v3 HubspotCRM: sourceNamespace: hubspot-crm - sourceRevisionDigest: sha256:068f049648f508cd2c1f0b3f74fdec83a2920b10763541b84a05644ba5fac7f9 + sourceRevisionDigest: sha256:4b920509e176a73262dfd4a386791f13a0bdbd538caf6dee3f680981dbfb657b sourceBlobDigest: sha256:fd3bb26f0d19170b271fae7398ffb1b2dbe48799b6e7c4dee95ec5c58302f332 tags: - latest - - speakeasy-sdk-regen-1742493224 + - speakeasy-sdk-regen-1743711404 - v3 targets: hubspot: source: HubspotCRM sourceNamespace: hubspot-crm - sourceRevisionDigest: sha256:068f049648f508cd2c1f0b3f74fdec83a2920b10763541b84a05644ba5fac7f9 + sourceRevisionDigest: sha256:4b920509e176a73262dfd4a386791f13a0bdbd538caf6dee3f680981dbfb657b sourceBlobDigest: sha256:fd3bb26f0d19170b271fae7398ffb1b2dbe48799b6e7c4dee95ec5c58302f332 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..14d455b 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-06-16 00:18:32 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.563.1 (2.629.1) 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/updatecompanyrequest.md b/docs/models/operations/updatecompanyrequest.md index 28d94d4..0d3285c 100644 --- a/docs/models/operations/updatecompanyrequest.md +++ b/docs/models/operations/updatecompanyrequest.md @@ -7,16 +7,6 @@ import { UpdateCompanyRequest } from "mcp-hubspot/models/operations"; let value: UpdateCompanyRequest = { companyId: "", - simplePublicObjectInput: { - properties: { - "amount": "1500.00", - "dealname": "Custom data integrations", - "pipeline": "default", - "closedate": "2019-12-07T16:50:06.678Z", - "dealstage": "presentationscheduled", - "hubspot_owner_id": "910901", - }, - }, }; ``` 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/updatecontactrequest.md b/docs/models/operations/updatecontactrequest.md index e6ea0f6..e5f5593 100644 --- a/docs/models/operations/updatecontactrequest.md +++ b/docs/models/operations/updatecontactrequest.md @@ -7,16 +7,6 @@ import { UpdateContactRequest } from "mcp-hubspot/models/operations"; let value: UpdateContactRequest = { contactId: "", - simplePublicObjectInput: { - properties: { - "amount": "1500.00", - "dealname": "Custom data integrations", - "pipeline": "default", - "closedate": "2019-12-07T16:50:06.678Z", - "dealstage": "presentationscheduled", - "hubspot_owner_id": "910901", - }, - }, }; ``` 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/updatedealrequest.md b/docs/models/operations/updatedealrequest.md index 0b07839..69d2df9 100644 --- a/docs/models/operations/updatedealrequest.md +++ b/docs/models/operations/updatedealrequest.md @@ -7,16 +7,6 @@ import { UpdateDealRequest } from "mcp-hubspot/models/operations"; let value: UpdateDealRequest = { dealId: "", - simplePublicObjectInput: { - properties: { - "amount": "1500.00", - "dealname": "Custom data integrations", - "pipeline": "default", - "closedate": "2019-12-07T16:50:06.678Z", - "dealstage": "presentationscheduled", - "hubspot_owner_id": "910901", - }, - }, }; ``` 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..516db76 100644 --- a/docs/sdks/basic/README.md +++ b/docs/sdks/basic/README.md @@ -30,10 +30,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 +55,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(); @@ -109,7 +105,6 @@ async function run() { companyId: "", }); - // Handle the result console.log(result); } @@ -134,15 +129,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(); @@ -185,18 +177,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 +212,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(); @@ -283,7 +269,6 @@ async function run() { contactId: "", }); - // Handle the result console.log(result); } @@ -308,15 +293,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(); @@ -359,18 +341,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 +376,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(); @@ -477,7 +453,6 @@ async function run() { }, }); - // Handle the result console.log(result); } @@ -522,15 +497,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(); @@ -573,7 +545,6 @@ async function run() { dealId: "", }); - // Handle the result console.log(result); } @@ -598,15 +569,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(); @@ -649,18 +617,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 +652,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(); @@ -767,7 +729,6 @@ async function run() { }, }); - // Handle the result console.log(result); } @@ -812,15 +773,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..d03c185 100644 --- a/docs/sdks/search/README.md +++ b/docs/sdks/search/README.md @@ -25,7 +25,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchCompanies({}); - // Handle the result console.log(result); } @@ -48,15 +47,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(); @@ -97,7 +93,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchContacts({}); - // Handle the result console.log(result); } @@ -120,15 +115,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(); @@ -167,7 +159,6 @@ const hubspot = new Hubspot({ async function run() { const result = await hubspot.search.searchDeals({}); - // Handle the result console.log(result); } @@ -190,15 +181,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/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..1429a37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "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", "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", @@ -23,10 +23,10 @@ "tshy": "^2.0.0", "typescript": "^5.4.5", "typescript-eslint": "^8.22.0", - "zod": "^3.23.4" + "zod": "^3.25.17" }, "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.5.0", + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0", "zod": ">= 3" }, "peerDependenciesMeta": { @@ -4046,9 +4046,9 @@ } }, "node_modules/zod": { - "version": "3.24.2", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", - "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", + "version": "3.25.64", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.64.tgz", + "integrity": "sha512-hbP9FpSZf7pkS7hRVUrOjhwKJNyampPgtXKc3AN6DsWtoHsg2Sb4SQaS4Tcay380zSwd2VPo9G9180emBACp5g==", "dev": true, "license": "MIT", "funding": { diff --git a/package.json b/package.json index 8006f37..9f50335 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,7 +33,7 @@ "prepublishOnly": "npm run build" }, "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.5.0", + "@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0", "zod": ">= 3" }, "peerDependenciesMeta": { @@ -43,7 +43,7 @@ }, "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", @@ -54,7 +54,7 @@ "tshy": "^2.0.0", "typescript": "^5.4.5", "typescript-eslint": "^8.22.0", - "zod": "^3.23.4" + "zod": "^3.25.17" }, "dependencies": {}, "exports": { 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..fcffb24 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.629.1", + userAgent: "speakeasy-sdk/typescript 0.2.0 2.629.1 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/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..06f12dc 100644 --- a/src/models/errors/apierror.ts +++ b/src/models/errors/apierror.ts @@ -2,26 +2,33 @@ * 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" : " "; + message += `Body ${body}`; + 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";