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

Function fetchAllTeamProjects

apps/sim/app/api/tools/linear/projects/route.ts:33–58  ·  view source on GitHub ↗

* Drains a single team's projects connection by following * `pageInfo.endCursor` until `hasNextPage` is false. Bounded by * `MAX_PROJECTS_PAGES`; logs a warning if the cap is hit so a truncated list * is visible rather than silently dropped.

(team: Team)

Source from the content-addressed store, hash-verified

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

Callers 1

route.tsFile · 0.85

Calls 2

warnMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected