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

Function listRepoFiles

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

* Lists a single batch of repository-file stubs. The full filtered file list is * resolved once and cached on syncContext; the cursor is an offset into that * list, of the form `file|{offset}`.

(
  accessToken: string,
  organization: string,
  project: string,
  filters: FileFilters,
  maxItems: number,
  cursor: string | undefined,
  syncContext: Record<string, unknown> | undefined
)

Source from the content-addressed store, hash-verified

950 * list, of the form `file|{offset}`.
951 */
952async function listRepoFiles(
953 accessToken: string,
954 organization: string,
955 project: string,
956 filters: FileFilters,
957 maxItems: number,
958 cursor: string | undefined,
959 syncContext: Record<string, unknown> | undefined
960): Promise<ExternalDocumentList> {
961 const entries = await resolveRepoFiles(accessToken, organization, project, filters, syncContext)
962
963 if (entries.length === 0) {
964 return { documents: [], hasMore: false }
965 }
966
967 let offset = 0
968 if (cursor) {
969 const parts = cursor.split('|')
970 offset = Number(parts[1]) || 0
971 }
972
973 const chunk = entries.slice(offset, offset + FILE_BATCH_SIZE)
974 const documents = chunk.map((entry) => fileToStub(organization, project, entry))
975
976 const nextOffset = offset + FILE_BATCH_SIZE
977 const { documents: capped, capped: hitLimit } = applyMaxItemsCap(
978 documents,
979 maxItems,
980 syncContext,
981 nextOffset < entries.length
982 )
983
984 const hasMore = !hitLimit && nextOffset < entries.length
985
986 return {
987 documents: capped,
988 nextCursor: hasMore ? `file|${nextOffset}` : undefined,
989 hasMore,
990 }
991}
992
993/**
994 * Resolves the branch to fetch a single repository file from in getDocument. Uses

Callers 1

runPhaseFunction · 0.85

Calls 3

resolveRepoFilesFunction · 0.85
fileToStubFunction · 0.70
applyMaxItemsCapFunction · 0.70

Tested by

no test coverage detected