MCPcopy
hub / github.com/simstudioai/sim / fetchAllTeams

Function fetchAllTeams

apps/sim/app/api/tools/linear/teams/route.ts:32–56  ·  view source on GitHub ↗

* Drains the full Linear teams connection by following * `pageInfo.endCursor` until `hasNextPage` is false. Bounded by * `MAX_TEAMS_PAGES`; logs a warning if the cap is hit so a truncated list is * visible rather than silently dropped.

(linearClient: LinearClient)

Source from the content-addressed store, hash-verified

30 * visible rather than silently dropped.
31 */
32async function fetchAllTeams(linearClient: LinearClient): Promise<Team[]> {
33 const teams: Team[] = []
34 let after: string | undefined
35
36 for (let page = 0; page < MAX_TEAMS_PAGES; page++) {
37 const result = await linearClient.teams({ first: LINEAR_PAGE_SIZE, after })
38 teams.push(...result.nodes)
39
40 if (!result.pageInfo.hasNextPage) {
41 return teams
42 }
43 after = result.pageInfo.endCursor ?? undefined
44 if (!after) {
45 return teams
46 }
47 if (page === MAX_TEAMS_PAGES - 1) {
48 logger.warn('Linear teams pagination hit cap; team list may be incomplete', {
49 cap: MAX_TEAMS_PAGES,
50 fetched: teams.length,
51 })
52 }
53 }
54
55 return teams
56}
57
58export const POST = withRouteHandler(async (request: NextRequest) => {
59 try {

Callers 1

route.tsFile · 0.85

Calls 2

warnMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected