* Creates a lightweight stub from a Drive file entry. Content is deferred * and only fetched via getDocument for new or changed documents.
(file: DriveFile)
| 135 | * and only fetched via getDocument for new or changed documents. |
| 136 | */ |
| 137 | function fileToStub(file: DriveFile): ExternalDocument { |
| 138 | return { |
| 139 | externalId: file.id, |
| 140 | title: file.name || 'Untitled', |
| 141 | content: '', |
| 142 | contentDeferred: true, |
| 143 | mimeType: 'text/plain', |
| 144 | sourceUrl: file.webViewLink || `https://docs.google.com/document/d/${file.id}/edit`, |
| 145 | contentHash: `gdocs:${file.id}:${file.modifiedTime ?? ''}`, |
| 146 | metadata: { |
| 147 | modifiedTime: file.modifiedTime, |
| 148 | createdTime: file.createdTime, |
| 149 | owners: file.owners?.map((o) => o.displayName || o.emailAddress).filter(Boolean), |
| 150 | }, |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * Builds the Drive API query string for listing Google Docs. |