Skip to content

Commit 839c00a

Browse files
committed
fix(connectors): address PR review comments for hubspot, jira, salesforce
- HubSpot: revert to Search API (POST /search) to restore lastmodifieddate DESCENDING sorting - Salesforce: restore ArticleBody field and add it to HTML_FIELDS for proper stripping - Jira: add zero-remaining guard to prevent requesting 0 maxResults
1 parent 4649033 commit 839c00a

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

apps/sim/connectors/hubspot/hubspot.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,28 @@ export const hubspotConnector: ConnectorConfig = {
223223

224224
const portalId = await getPortalId(accessToken, syncContext)
225225

226-
const params = new URLSearchParams({
227-
limit: String(PAGE_SIZE),
228-
})
229-
for (const prop of properties) {
230-
params.append('properties', prop)
226+
const sortProperty = objectType === 'contacts' ? 'lastmodifieddate' : 'hs_lastmodifieddate'
227+
228+
const searchBody: Record<string, unknown> = {
229+
properties,
230+
sorts: [{ propertyName: sortProperty, direction: 'DESCENDING' }],
231+
limit: PAGE_SIZE,
231232
}
232233
if (cursor) {
233-
params.set('after', cursor)
234+
searchBody.after = cursor
234235
}
235236

236237
logger.info(`Listing HubSpot ${objectType}`, { cursor })
237238

238-
const response = await fetchWithRetry(
239-
`${BASE_URL}/crm/v3/objects/${objectType}?${params.toString()}`,
240-
{
241-
method: 'GET',
242-
headers: {
243-
Accept: 'application/json',
244-
Authorization: `Bearer ${accessToken}`,
245-
},
246-
}
247-
)
239+
const response = await fetchWithRetry(`${BASE_URL}/crm/v3/objects/${objectType}/search`, {
240+
method: 'POST',
241+
headers: {
242+
'Content-Type': 'application/json',
243+
Accept: 'application/json',
244+
Authorization: `Bearer ${accessToken}`,
245+
},
246+
body: JSON.stringify(searchBody),
247+
})
248248

249249
if (!response.ok) {
250250
const errorText = await response.text()

apps/sim/connectors/jira/jira.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ export const jiraConnector: ConnectorConfig = {
155155
const params = new URLSearchParams()
156156
params.append('jql', jql)
157157
params.append('startAt', String(startAt))
158-
const remaining = maxIssues > 0 ? maxIssues - startAt : PAGE_SIZE
158+
const remaining = maxIssues > 0 ? Math.max(0, maxIssues - startAt) : PAGE_SIZE
159+
if (remaining === 0) {
160+
return { documents: [], hasMore: false }
161+
}
159162
params.append('maxResults', String(Math.min(PAGE_SIZE, remaining)))
160163
params.append(
161164
'fields',

apps/sim/connectors/salesforce/salesforce.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ const PAGE_SIZE = 200
1212

1313
/** SOQL field lists per object type. */
1414
const OBJECT_FIELDS: Record<string, string[]> = {
15-
KnowledgeArticleVersion: ['Id', 'Title', 'Summary', 'LastModifiedDate', 'ArticleNumber'],
15+
KnowledgeArticleVersion: [
16+
'Id',
17+
'Title',
18+
'Summary',
19+
'ArticleBody',
20+
'LastModifiedDate',
21+
'ArticleNumber',
22+
],
1623
Case: ['Id', 'Subject', 'Description', 'Status', 'LastModifiedDate', 'CaseNumber'],
1724
Account: ['Id', 'Name', 'Description', 'Industry', 'LastModifiedDate'],
1825
Opportunity: [
@@ -92,7 +99,7 @@ function buildRecordTitle(objectType: string, record: Record<string, unknown>):
9299
}
93100

94101
/** Fields that may contain HTML content and should be stripped to plain text. */
95-
const HTML_FIELDS = new Set(['Description', 'Summary'])
102+
const HTML_FIELDS = new Set(['Description', 'Summary', 'ArticleBody'])
96103

97104
/**
98105
* Builds plain-text content from a Salesforce record for indexing.

0 commit comments

Comments
 (0)