Skip to content

Commit 00bee48

Browse files
committed
fix(integrations): return the Dataverse page size and correct Contacts search outputs
- Dataverse List Records returns the page size it sent (odata.maxpagesize) so a loop can pass it back with nextLink, since Dataverse requires the same value on every page; the request header and the output share one resolver - Page Size placeholder and input description now say the default applies only without Max Results and that the value must stay the same across Next Page Link pages - Google Contacts metadata description no longer claims search returns nextPageToken/totalItems
1 parent 55bacfc commit 00bee48

6 files changed

Lines changed: 36 additions & 10 deletions

File tree

‎apps/docs/content/docs/integrations/microsoft_dataverse.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ Query and list records from a Microsoft Dataverse table. Supports OData query op
356356
| `count` | number | Number of records returned in the current page |
357357
| `totalCount` | number | Total number of matching records server-side \(requires $count=true\) |
358358
| `nextLink` | string | URL for the next page of results |
359+
| `pageSize` | number | Page size sent as odata.maxpagesize \(null when Max Results applied instead\); pass it with nextLink, since Dataverse requires the same value on every page |
359360
| `success` | boolean | Operation success status |
360361

361362
</ReferenceDetails>

‎apps/sim/blocks/blocks/google_contacts.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ Return ONLY the date - no explanations, no extra text.`,
316316
metadata: {
317317
type: 'json',
318318
description:
319-
'Contact (resourceName, etag, displayName, givenName, familyName, middleName, emails, phones, organizations, addresses, biographies, urls, photos, birthdays, events, nicknames, relations, userDefined, contactGroupResourceNames), or for list/search {contacts, nextPageToken, totalItems}',
319+
'Contact (resourceName, etag, displayName, givenName, familyName, middleName, emails, phones, organizations, addresses, biographies, urls, photos, birthdays, events, nicknames, relations, userDefined, contactGroupResourceNames), list {contacts, nextPageToken, totalItems}, or search {contacts}',
320320
},
321321
},
322322
}

‎apps/sim/blocks/blocks/microsoft_dataverse.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ Return ONLY the orderby expression - no $orderby= prefix, no explanations.`,
547547
id: 'pageSize',
548548
title: 'Page Size',
549549
type: 'short-input',
550-
placeholder: 'Records per page, 1-5000 (default: 100)',
550+
placeholder: '1-5000 (default 100 when Max Results is empty); reuse with Next Page Link',
551551
condition: { field: 'operation', value: 'list_records' },
552552
mode: 'advanced',
553553
},
@@ -712,7 +712,11 @@ Return ONLY the expand expression - no $expand= prefix, no explanations.`,
712712
description: 'Set to "true" to include total record count in the response (list records)',
713713
},
714714
expand: { type: 'string', description: 'Navigation properties to expand' },
715-
pageSize: { type: 'string', description: 'Records per page for list records (1-5000)' },
715+
pageSize: {
716+
type: 'string',
717+
description:
718+
'Records per page for list records (1-5000); keep unchanged across Next Page Link pages',
719+
},
716720
nextLink: { type: 'string', description: 'nextLink from a previous list records page' },
717721
returnRecord: {
718722
type: 'boolean',
@@ -770,6 +774,10 @@ Return ONLY the expand expression - no $expand= prefix, no explanations.`,
770774
description: 'Total matching records server-side',
771775
},
772776
nextLink: { type: 'string', description: 'URL for next page of results' },
777+
pageSize: {
778+
type: 'number',
779+
description: 'Page size sent for list records; pass it with nextLink for the next page',
780+
},
773781
created: { type: 'boolean', description: 'Whether a new record was created (upsert)' },
774782
userId: { type: 'string', description: 'Authenticated user ID (WhoAmI)' },
775783
businessUnitId: { type: 'string', description: 'Business unit ID (WhoAmI)' },

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/microsoft_dataverse/list_records.ts‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ function getExplicitPageSize(params: DataverseListRecordsParams): number | undef
2626
return pageSize
2727
}
2828

29+
/**
30+
* Page size sent as `Prefer: odata.maxpagesize`. Dataverse ignores `$top` when a page size is
31+
* sent, so the default applies only when no `$top` was requested, except on `nextLink` pages,
32+
* which must keep paging.
33+
*/
34+
function resolvePageSize(params: DataverseListRecordsParams): number | undefined {
35+
return (
36+
getExplicitPageSize(params) ??
37+
(params.nextLink || !isSet(params.top) ? DATAVERSE_DEFAULT_PAGE_SIZE : undefined)
38+
)
39+
}
40+
2941
/** Dataverse serves the same environment on `org.crm…` and `org.api.crm…`; compare them as one host. */
3042
function environmentHost(url: URL): string {
3143
return url.host.toLowerCase().replace(/^([^.]+)\.api\./, '$1.')
@@ -171,12 +183,8 @@ export const dataverseListRecordsTool: ToolConfig<
171183
*/
172184
stripAuthOnRedirect: true,
173185
headers: (params) => {
174-
// Dataverse ignores $top entirely when Prefer: odata.maxpagesize is also sent, so the
175-
// default page-size preference is only applied when the caller hasn't requested a $top.
176186
const preferParts = ['odata.include-annotations="*"']
177-
const pageSize =
178-
getExplicitPageSize(params) ??
179-
(params.nextLink || !isSet(params.top) ? DATAVERSE_DEFAULT_PAGE_SIZE : undefined)
187+
const pageSize = resolvePageSize(params)
180188
if (pageSize !== undefined) {
181189
preferParts.push(`odata.maxpagesize=${pageSize}`)
182190
}
@@ -190,7 +198,7 @@ export const dataverseListRecordsTool: ToolConfig<
190198
},
191199
},
192200

193-
transformResponse: async (response: Response) => {
201+
transformResponse: async (response: Response, params?: DataverseListRecordsParams) => {
194202
if (!response.ok) {
195203
const errorData = await response.json().catch(() => ({}))
196204
const errorMessage =
@@ -212,6 +220,7 @@ export const dataverseListRecordsTool: ToolConfig<
212220
count: records.length,
213221
totalCount,
214222
nextLink,
223+
pageSize: params ? (resolvePageSize(params) ?? null) : null,
215224
success: true,
216225
},
217226
}
@@ -230,6 +239,13 @@ export const dataverseListRecordsTool: ToolConfig<
230239
description: 'URL for the next page of results',
231240
optional: true,
232241
},
242+
pageSize: {
243+
type: 'number',
244+
description:
245+
'Page size sent as odata.maxpagesize (null when Max Results applied instead); pass it with nextLink, since Dataverse requires the same value on every page',
246+
optional: true,
247+
nullable: true,
248+
},
233249
success: { type: 'boolean', description: 'Operation success status' },
234250
},
235251
}

‎apps/sim/tools/microsoft_dataverse/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export interface DataverseListRecordsResponse extends ToolResponse {
135135
count: number
136136
totalCount: number | null
137137
nextLink: string | null
138+
pageSize: number | null
138139
success: boolean
139140
}
140141
}

0 commit comments

Comments
 (0)