From 7e7e5df35958fe5ca099a912e5a0b4ce5aacd761 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Fri, 12 Sep 2025 14:11:31 -0400 Subject: [PATCH 1/4] update search-crm --- .../hubspot/actions/search-crm/search-crm.mjs | 36 +++++++++++++++++-- components/hubspot/package.json | 2 +- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/components/hubspot/actions/search-crm/search-crm.mjs b/components/hubspot/actions/search-crm/search-crm.mjs index a879af3b5a1e1..8ccf9733ae155 100644 --- a/components/hubspot/actions/search-crm/search-crm.mjs +++ b/components/hubspot/actions/search-crm/search-crm.mjs @@ -18,7 +18,7 @@ export default { name: "Search CRM", description: "Search companies, contacts, deals, feedback submissions, products, tickets, line-items, quotes, leads, or custom objects. [See the documentation](https://developers.hubspot.com/docs/api/crm/search)", - version: "1.0.12", + version: "1.0.13", type: "action", props: { hubspot, @@ -42,6 +42,13 @@ export default { "Set to `true` to search for an exact match of the search value. If `false`, partial matches will be returned. Default: `true`", default: true, optional: true, + reloadProps: true, + }, + createdAfter: { + type: "string", + label: "Created After", + description: "Filter results to only include objects created after this date. Example: `2023-03-03T16:16:24.400Z`. Recommended when `Exact Match` is set to `false`.", + optional: true, }, createIfNotFound: { type: "boolean", @@ -56,6 +63,14 @@ export default { async additionalProps() { const props = {}; + if (this.exactMatch === false && !this.createdAfter) { + props.exactMatchAlert = { + type: "alert", + alertType: "info", + content: "It is recommended to set `Created After` when `Exact Match` is set to `false` to avoid potential timeouts.", + }; + } + if (this.objectType === "custom_object") { try { props.customObjectType = { @@ -225,9 +240,9 @@ export default { ); }, async paginate(params) { - let results; + let results, done = false; const items = []; - while (!results || params.after) { + while ((!results || params.after) && !done) { results = await this.hubspot.searchCRM(params); if (results.paging) { params.after = results.paging.next.after; @@ -236,6 +251,12 @@ export default { } results = results.results; for (const result of results) { + if (this.createdAfter + && Date.parse(result.properties.createdate) <= Date.parse(this.createdAfter) + ) { + done = true; + break; + } items.push(result); } } @@ -252,6 +273,8 @@ export default { searchValue, exactMatch, /* eslint-disable no-unused-vars */ + createdAfter, + exactMatchAlert, info, createIfNotFound, creationProps, @@ -282,6 +305,13 @@ export default { properties: [ ...defaultProperties, ...additionalProperties, + searchProperty, + ], + sorts: [ + { + propertyName: "createdate", + direction: "DESCENDING", + }, ], }; if (exactMatch) { diff --git a/components/hubspot/package.json b/components/hubspot/package.json index d48ffa29dac04..f8fcd6358459d 100644 --- a/components/hubspot/package.json +++ b/components/hubspot/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hubspot", - "version": "1.7.3", + "version": "1.7.4", "description": "Pipedream Hubspot Components", "main": "hubspot.app.mjs", "keywords": [ From 2ce3b3d5dfbdc332c8863420899760cbce1f0271 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 15 Sep 2025 13:47:09 -0400 Subject: [PATCH 2/4] limit results to one page --- .../hubspot/actions/search-crm/search-crm.mjs | 66 ++++++------------- 1 file changed, 20 insertions(+), 46 deletions(-) diff --git a/components/hubspot/actions/search-crm/search-crm.mjs b/components/hubspot/actions/search-crm/search-crm.mjs index 8ccf9733ae155..6b4a67508235b 100644 --- a/components/hubspot/actions/search-crm/search-crm.mjs +++ b/components/hubspot/actions/search-crm/search-crm.mjs @@ -4,7 +4,6 @@ import { DEFAULT_CONTACT_PROPERTIES, DEFAULT_DEAL_PROPERTIES, DEFAULT_LEAD_PROPERTIES, - DEFAULT_LIMIT, DEFAULT_LINE_ITEM_PROPERTIES, DEFAULT_PRODUCT_PROPERTIES, DEFAULT_TICKET_PROPERTIES, @@ -12,6 +11,7 @@ import { } from "../../common/constants.mjs"; import hubspot from "../../hubspot.app.mjs"; import common from "../common/common-create.mjs"; +const DEFAULT_LIMIT = 200; export default { key: "hubspot-search-crm", @@ -42,13 +42,6 @@ export default { "Set to `true` to search for an exact match of the search value. If `false`, partial matches will be returned. Default: `true`", default: true, optional: true, - reloadProps: true, - }, - createdAfter: { - type: "string", - label: "Created After", - description: "Filter results to only include objects created after this date. Example: `2023-03-03T16:16:24.400Z`. Recommended when `Exact Match` is set to `false`.", - optional: true, }, createIfNotFound: { type: "boolean", @@ -59,18 +52,17 @@ export default { optional: true, reloadProps: true, }, + offset: { + type: "integer", + label: "Offset", + description: "The offset to start from. Used for pagination.", + default: 0, + optional: true, + }, }, async additionalProps() { const props = {}; - if (this.exactMatch === false && !this.createdAfter) { - props.exactMatchAlert = { - type: "alert", - alertType: "info", - content: "It is recommended to set `Created After` when `Exact Match` is set to `false` to avoid potential timeouts.", - }; - } - if (this.objectType === "custom_object") { try { props.customObjectType = { @@ -239,29 +231,6 @@ export default { })) || [] ); }, - async paginate(params) { - let results, done = false; - const items = []; - while ((!results || params.after) && !done) { - results = await this.hubspot.searchCRM(params); - if (results.paging) { - params.after = results.paging.next.after; - } else { - delete params.after; - } - results = results.results; - for (const result of results) { - if (this.createdAfter - && Date.parse(result.properties.createdate) <= Date.parse(this.createdAfter) - ) { - done = true; - break; - } - items.push(result); - } - } - return items; - }, }, async run({ $ }) { const { @@ -272,9 +241,8 @@ export default { searchProperty, searchValue, exactMatch, + offset, /* eslint-disable no-unused-vars */ - createdAfter, - exactMatchAlert, info, createIfNotFound, creationProps, @@ -313,7 +281,10 @@ export default { direction: "DESCENDING", }, ], + limit: DEFAULT_LIMIT, + after: offset, }; + if (exactMatch) { data.filters = [ { @@ -322,17 +293,17 @@ export default { value: searchValue, }, ]; - } else { - data.limit = DEFAULT_LIMIT; } - let results = await this.paginate({ + let { + results, paging, + } = await this.hubspot.searchCRM({ object: actualObjectType, data, }); if (!exactMatch) { - results = results.filter( + results = results?.filter( (result) => result.properties[searchProperty] && result.properties[searchProperty] @@ -358,6 +329,9 @@ export default { "$summary", `Successfully retrieved ${results?.length} object(s).`, ); - return results; + return { + results, + paging, + }; }, }; From 102495a1cff78c617963d8fe5b4fee4a1b33dd23 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Mon, 15 Sep 2025 13:50:19 -0400 Subject: [PATCH 3/4] update version --- components/hubspot/actions/search-crm/search-crm.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hubspot/actions/search-crm/search-crm.mjs b/components/hubspot/actions/search-crm/search-crm.mjs index 6b4a67508235b..12aa6cd77e206 100644 --- a/components/hubspot/actions/search-crm/search-crm.mjs +++ b/components/hubspot/actions/search-crm/search-crm.mjs @@ -18,7 +18,7 @@ export default { name: "Search CRM", description: "Search companies, contacts, deals, feedback submissions, products, tickets, line-items, quotes, leads, or custom objects. [See the documentation](https://developers.hubspot.com/docs/api/crm/search)", - version: "1.0.13", + version: "1.1.0", type: "action", props: { hubspot, From f490be570c1428002aa011e45a1c317febdf3ee9 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Tue, 16 Sep 2025 11:02:21 -0400 Subject: [PATCH 4/4] package.json version --- components/hubspot/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hubspot/package.json b/components/hubspot/package.json index f8fcd6358459d..9d6372eacca78 100644 --- a/components/hubspot/package.json +++ b/components/hubspot/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hubspot", - "version": "1.7.4", + "version": "1.7.5", "description": "Pipedream Hubspot Components", "main": "hubspot.app.mjs", "keywords": [