* Lists items in a folder. When folderId is omitted the root of the default * document library is listed.
( accessToken: string, siteId: string, folderId?: string, nextLink?: string )
| 198 | * document library is listed. |
| 199 | */ |
| 200 | async function listFolderItems( |
| 201 | accessToken: string, |
| 202 | siteId: string, |
| 203 | folderId?: string, |
| 204 | nextLink?: string |
| 205 | ): Promise<DriveItemListResponse> { |
| 206 | const url = |
| 207 | nextLink ?? |
| 208 | (folderId |
| 209 | ? `${GRAPH_BASE}/sites/${siteId}/drive/items/${folderId}/children?$top=200` |
| 210 | : `${GRAPH_BASE}/sites/${siteId}/drive/root/children?$top=200`) |
| 211 | |
| 212 | const response = await fetchWithRetry(url, { |
| 213 | method: 'GET', |
| 214 | headers: { |
| 215 | Authorization: `Bearer ${accessToken}`, |
| 216 | Accept: 'application/json', |
| 217 | }, |
| 218 | }) |
| 219 | |
| 220 | if (!response.ok) { |
| 221 | const errorText = await response.text() |
| 222 | throw new Error(`Failed to list folder items: ${response.status} – ${errorText}`) |
| 223 | } |
| 224 | |
| 225 | return response.json() as Promise<DriveItemListResponse> |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Resolves a slash-separated folder path (e.g. "Documents/Reports") to a |
no test coverage detected