MCPcopy Index your code
hub / github.com/simstudioai/sim / applyMaxItemsCap

Function applyMaxItemsCap

apps/sim/connectors/azure-devops/azure-devops.ts:1166–1182  ·  view source on GitHub ↗

* Applies the optional maxItems cap to a batch, tracking the running total in * syncContext and flagging `listingCapped` when the cap actually truncated the * listing. The sync engine reads `listingCapped` to suppress deletion * reconciliation on a truncated listing — without it, a capped full sy

(
  documents: ExternalDocument[],
  maxItems: number,
  syncContext: Record<string, unknown> | undefined,
  moreAvailable: boolean
)

Source from the content-addressed store, hash-verified

1164 * documents are still cleaned up.
1165 */
1166function applyMaxItemsCap(
1167 documents: ExternalDocument[],
1168 maxItems: number,
1169 syncContext: Record<string, unknown> | undefined,
1170 moreAvailable: boolean
1171): { documents: ExternalDocument[]; capped: boolean } {
1172 if (maxItems <= 0) return { documents, capped: false }
1173 const prevTotal = (syncContext?.totalDocsFetched as number) ?? 0
1174 const remaining = Math.max(0, maxItems - prevTotal)
1175 const slicedSome = documents.length > remaining
1176 const sliced = slicedSome ? documents.slice(0, remaining) : documents
1177 const newTotal = prevTotal + sliced.length
1178 if (syncContext) syncContext.totalDocsFetched = newTotal
1179 const capped = newTotal >= maxItems
1180 if (capped && (slicedSome || moreAvailable) && syncContext) syncContext.listingCapped = true
1181 return { documents: sliced, capped }
1182}
1183
1184/**
1185 * Lists a single batch of wiki pages across the project's wikis (optionally

Callers 3

listRepoFilesFunction · 0.70
listWikiPagesFunction · 0.70
listWorkItemsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected