* Fetches all project GIDs in a workspace, used when no specific project is configured.
( accessToken: string, workspaceGid: string )
| 109 | * Fetches all project GIDs in a workspace, used when no specific project is configured. |
| 110 | */ |
| 111 | async function listWorkspaceProjects( |
| 112 | accessToken: string, |
| 113 | workspaceGid: string |
| 114 | ): Promise<AsanaProject[]> { |
| 115 | const projects: AsanaProject[] = [] |
| 116 | let offset: string | undefined |
| 117 | |
| 118 | // eslint-disable-next-line no-constant-condition |
| 119 | while (true) { |
| 120 | const offsetParam = offset ? `&offset=${offset}` : '' |
| 121 | const result = await asanaGet<{ data: AsanaProject[]; next_page: { offset: string } | null }>( |
| 122 | accessToken, |
| 123 | `/projects?workspace=${workspaceGid}&limit=100${offsetParam}` |
| 124 | ) |
| 125 | projects.push(...result.data) |
| 126 | if (!result.next_page) break |
| 127 | offset = result.next_page.offset |
| 128 | } |
| 129 | |
| 130 | return projects |
| 131 | } |
| 132 | |
| 133 | export const asanaConnector: ConnectorConfig = { |
| 134 | ...asanaConnectorMeta, |