UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

124 lines • 5.3 kB
import { ByteSpool } from '../../io/spool.ts'; import type { ByteWindow } from '../../utils/ranges.ts'; import type { TokenManager } from './client.ts'; export declare const MIME_TO_EXT: Readonly<Record<string, string>>; interface DriveOwner { me?: boolean; displayName?: string; emailAddress?: string; } export interface DriveFile { id: string; name: string; mimeType?: string; driveId?: string; size?: string; quotaBytesUsed?: string; createdTime?: string; modifiedTime?: string; md5Checksum?: string; sha1Checksum?: string; sha256Checksum?: string; headRevisionId?: string; trashed?: boolean; owners?: DriveOwner[]; capabilities?: { canEdit?: boolean; }; parents?: string[]; } export interface SharedDrive { id: string; name: string; } export declare function listFiles(tm: TokenManager, opts?: { folderId?: string; driveId?: string | null; mimeType?: string | null; trashed?: boolean; pageSize?: number; modifiedAfter?: string | null; modifiedBefore?: string | null; name?: string | null; /** * Stop once this many files are in hand and do not request another * page. An emptiness probe wants one entry, and `pageSize` alone * cannot express that: it caps the page, not the walk, so a small * page turned a listing of a large folder into many requests * instead of fewer. */ limit?: number | null; }): Promise<DriveFile[]>; /** * The untrashed children of several folders of one corpus, from one query * (`'a' in parents or 'b' in parents`), in the order a listing of each folder * returns them, stopping once `limit` files are in hand. Mirrors Python's * `list_children`. */ export declare function listChildren(tm: TokenManager, folderIds: readonly string[], driveId?: string | null, pageSize?: number, limit?: number): Promise<DriveFile[]>; export declare function listSharedDrives(tm: TokenManager, opts?: { pageSize?: number; }): Promise<SharedDrive[]>; export declare function listAllFiles(tm: TokenManager, opts?: { mimeType?: string | null; trashed?: boolean; pageSize?: number; modifiedAfter?: string | null; modifiedBefore?: string | null; }): Promise<{ files: DriveFile[]; complete: boolean; }>; /** * Ids of the files in `parentIds` Drive full-text search names, and whether * Drive searched every corpus it was asked for. Drive sorts no `fullText` * query, so none is asked for. */ export declare function searchFiles(tm: TokenManager, text: string, parentIds: readonly string[], mimeType?: string | null, pageSize?: number): Promise<{ ids: string[]; complete: boolean; }>; export declare function downloadFile(tm: TokenManager, fileId: string, window?: ByteWindow): Promise<Uint8Array>; /** Stream a regular file from Drive as it downloads. */ export declare function downloadFileStream(tm: TokenManager, fileId: string): AsyncGenerator<Uint8Array, void>; /** A pinned revision's content (binary files only). */ export declare function downloadRevision(tm: TokenManager, fileId: string, revisionId: string, window?: ByteWindow): Promise<Uint8Array>; /** Stream a pinned revision's content as it downloads. */ export declare function downloadRevisionStream(tm: TokenManager, fileId: string, revisionId: string): AsyncGenerator<Uint8Array, void>; export declare function deleteFile(tm: TokenManager, fileId: string): Promise<void>; export declare const FOLDER_MIME = "application/vnd.google-apps.folder"; /** One entry of Drive's change feed. */ export interface DriveChange { changeType?: string; fileId?: string; removed?: boolean; file?: DriveFile; } /** * The changes page token at the present, which lists nothing. Mirrors Python * `start_page_token`. */ export declare function startPageToken(tm: TokenManager): Promise<string>; /** * Every change since `pageToken` across the account's drives, and the token * the next read starts from. Mirrors Python `list_changes`. */ export declare function listChanges(tm: TokenManager, pageToken: string): Promise<[DriveChange[], string]>; /** A file's metadata, the fields a listing names unless `fields` says others. */ export declare function getFile(tm: TokenManager, fileId: string, fields?: string): Promise<DriveFile>; /** The account's `storageQuota`, empty when Drive gives none. Mirrors Python `storage_quota`. */ export declare function storageQuota(tm: TokenManager): Promise<{ limit?: string; usage?: string; }>; export declare function createFolder(tm: TokenManager, name: string, parentId: string): Promise<DriveFile>; export declare function uploadFile(tm: TokenManager, name: string, parentId: string, data: Uint8Array | ByteSpool, mimeType?: string): Promise<DriveFile>; export declare function updateFileContent(tm: TokenManager, fileId: string, data: Uint8Array | ByteSpool, mimeType?: string): Promise<DriveFile>; export declare function patchFile(tm: TokenManager, fileId: string, opts?: { body?: Record<string, unknown>; addParents?: string; removeParents?: string; }): Promise<DriveFile>; export declare function copyFile(tm: TokenManager, fileId: string, name: string, parentId: string): Promise<DriveFile>; export {}; //# sourceMappingURL=drive.d.ts.map