Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ Query and list records from a Microsoft Dataverse table. Supports OData query op
| `count` | number | Number of records returned in the current page |
| `totalCount` | number | Total number of matching records server-side \(requires $count=true\) |
| `nextLink` | string | URL for the next page of results |
| `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 |
| `success` | boolean | Operation success status |

</ReferenceDetails>
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/google_contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Return ONLY the date - no explanations, no extra text.`,
metadata: {
type: 'json',
description:
'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}',
'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}',
},
},
}
Expand Down
13 changes: 11 additions & 2 deletions apps/sim/blocks/blocks/microsoft_dataverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ Return ONLY the orderby expression - no $orderby= prefix, no explanations.`,
id: 'pageSize',
title: 'Page Size',
type: 'short-input',
placeholder: 'Records per page, 1-5000 (default: 100)',
placeholder: '1-5000 (default 100 when Max Results is empty); reuse with Next Page Link',
condition: { field: 'operation', value: 'list_records' },
mode: 'advanced',
},
Expand Down Expand Up @@ -712,7 +712,11 @@ Return ONLY the expand expression - no $expand= prefix, no explanations.`,
description: 'Set to "true" to include total record count in the response (list records)',
},
expand: { type: 'string', description: 'Navigation properties to expand' },
pageSize: { type: 'string', description: 'Records per page for list records (1-5000)' },
pageSize: {
type: 'string',
description:
'Records per page for list records (1-5000); keep unchanged across Next Page Link pages',
},
nextLink: { type: 'string', description: 'nextLink from a previous list records page' },
returnRecord: {
type: 'boolean',
Expand Down Expand Up @@ -770,6 +774,11 @@ Return ONLY the expand expression - no $expand= prefix, no explanations.`,
description: 'Total matching records server-side',
},
nextLink: { type: 'string', description: 'URL for next page of results' },
pageSize: {
type: 'number',
description:
'Page size sent for list records (null when Max Results applied instead); pass it with nextLink for the next page',
},
created: { type: 'boolean', description: 'Whether a new record was created (upsert)' },
userId: { type: 'string', description: 'Authenticated user ID (WhoAmI)' },
businessUnitId: { type: 'string', description: 'Business unit ID (WhoAmI)' },
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-outputs.ts

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions apps/sim/tools/microsoft_dataverse/list_records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ function getExplicitPageSize(params: DataverseListRecordsParams): number | undef
return pageSize
}

/**
* Page size sent as `Prefer: odata.maxpagesize`. Dataverse ignores `$top` when a page size is
* sent, so the default applies only when no `$top` was requested, except on `nextLink` pages,
* which must keep paging.
*/
function resolvePageSize(params: DataverseListRecordsParams): number | undefined {
return (
getExplicitPageSize(params) ??
(params.nextLink || !isSet(params.top) ? DATAVERSE_DEFAULT_PAGE_SIZE : undefined)
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
)
}

/** Dataverse serves the same environment on `org.crm…` and `org.api.crm…`; compare them as one host. */
function environmentHost(url: URL): string {
return url.host.toLowerCase().replace(/^([^.]+)\.api\./, '$1.')
Expand Down Expand Up @@ -171,12 +183,8 @@ export const dataverseListRecordsTool: ToolConfig<
*/
stripAuthOnRedirect: true,
headers: (params) => {
// Dataverse ignores $top entirely when Prefer: odata.maxpagesize is also sent, so the
// default page-size preference is only applied when the caller hasn't requested a $top.
const preferParts = ['odata.include-annotations="*"']
const pageSize =
getExplicitPageSize(params) ??
(params.nextLink || !isSet(params.top) ? DATAVERSE_DEFAULT_PAGE_SIZE : undefined)
const pageSize = resolvePageSize(params)
if (pageSize !== undefined) {
preferParts.push(`odata.maxpagesize=${pageSize}`)
}
Expand All @@ -190,7 +198,7 @@ export const dataverseListRecordsTool: ToolConfig<
},
},

transformResponse: async (response: Response) => {
transformResponse: async (response: Response, params?: DataverseListRecordsParams) => {
if (!response.ok) {
const errorData = await response.json().catch(() => ({}))
const errorMessage =
Expand All @@ -212,6 +220,7 @@ export const dataverseListRecordsTool: ToolConfig<
count: records.length,
totalCount,
nextLink,
pageSize: params ? (resolvePageSize(params) ?? null) : null,
success: true,
},
}
Expand All @@ -230,6 +239,13 @@ export const dataverseListRecordsTool: ToolConfig<
description: 'URL for the next page of results',
optional: true,
},
pageSize: {
type: 'number',
description:
'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',
optional: true,
nullable: true,
},
success: { type: 'boolean', description: 'Operation success status' },
},
}
1 change: 1 addition & 0 deletions apps/sim/tools/microsoft_dataverse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface DataverseListRecordsResponse extends ToolResponse {
count: number
totalCount: number | null
nextLink: string | null
pageSize: number | null
success: boolean
}
}
Expand Down
Loading