UNPKG

@accounter/server

Version:
39 lines (38 loc) 1.55 kB
import type { Environment } from '../../../shared/types/index.js'; /** * Wall-clock budget for a single Drive exchange (metadata lookup or download). * * `fetch` has no default timeout, so without this a Drive call that never * answers pins the request forever: the caller eventually gives up while the * server keeps the operation — and its database client — alive with nothing to * show for it. A bounded failure is reportable; a hang is not. */ export declare const DRIVE_FETCH_TIMEOUT_MS = 60000; export declare class GoogleDriveProvider { private env; private apiKey; constructor(env: Environment); private fetchFolderContent; private fetchFile; private isRelevantFileType; /** * Whether a URL points at a single Google Drive *file* (as opposed to a * folder, which {@link fetchFilesFromSharedFolder} handles). */ static isFileUrl(rawUrl: string): boolean; /** * Pull the file id out of the several share-link shapes Drive hands out: * `/file/d/<id>/view`, `/open?id=<id>`, `/uc?id=<id>`. */ private static extractFileId; private fetchFileMetadata; /** * Fetch a single file from a Drive share link. * * A share link is not a download link — `/file/d/<id>/view` answers with an * HTML page — so the id is resolved through the Drive API for its real name * and MIME type before the bytes are pulled. */ fetchFileFromUrl(fileUrl: string): Promise<File>; fetchFilesFromSharedFolder(folderUrl: string): Promise<File[]>; }