| 15 | } |
| 16 | |
| 17 | export async function fetchTeams({ |
| 18 | linearClient, |
| 19 | accessToken, |
| 20 | }: { |
| 21 | linearClient?: LinearClient; |
| 22 | accessToken?: string; |
| 23 | }) { |
| 24 | if (!linearClient) { |
| 25 | linearClient = new LinearClient({ accessToken }); |
| 26 | } |
| 27 | |
| 28 | const teams = []; |
| 29 | |
| 30 | let response = await linearClient.teams(); |
| 31 | teams.push(...response.nodes.map(parseTeam)); |
| 32 | |
| 33 | let hasMore = response.pageInfo.hasNextPage; |
| 34 | while (hasMore) { |
| 35 | response = await linearClient.teams({ after: response.pageInfo.endCursor }); |
| 36 | teams.push(...response.nodes.map(parseTeam)); |
| 37 | hasMore = response.pageInfo.hasNextPage; |
| 38 | } |
| 39 | |
| 40 | return teams; |
| 41 | } |
| 42 | |
| 43 | type createMessageType = { |
| 44 | accessToken: string; |