# Google Drive API reference

> Exports of @anymux/google-drive.

Source: https://anymux-docs.n.yatsyk.com/docs/google-drive/jsdoc

## Classes

### GoogleDriveFileSystem

```ts
class GoogleDriveFileSystem
```

- `constructor(config: GoogleDriveConfig): GoogleDriveFileSystem`
- `readFile(path: string, options?: { encoding?: BufferEncoding; flag?: string; } | BufferEncoding): Promise<Buffer | string>`
- `writeFile(path: string, data: Buffer | string | Uint8Array, _options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>`
- `appendFile(path: string, data: Buffer | string | Uint8Array, options?: { encoding?: BufferEncoding; mode?: number; flag?: string; }): Promise<void>`
- `readdir(path: string, options?: { encoding?: BufferEncoding; withFileTypes?: false; recursive?: boolean; }): Promise<string[]>`
- `readdir(path: string, options: { encoding?: BufferEncoding; withFileTypes: true; recursive?: boolean; }): Promise<Dirent[]>`
- `readdir(path: string, options?: { encoding?: BufferEncoding; withFileTypes?: boolean; recursive?: boolean; }): Promise<string[] | Dirent[]>`
- `stat(path: string, options?: { bigint?: false; }): Promise<Stats>`
- `stat(path: string, options: { bigint: true; }): Promise<BigIntStats>`
- `stat(path: string, _options?: { bigint?: boolean; }): Promise<Stats | BigIntStats>`
- `lstat(path: string, options?: { bigint?: false; }): Promise<Stats>`
- `lstat(path: string, options: { bigint: true; }): Promise<BigIntStats>`
- `lstat(path: string, _options?: { bigint?: boolean; }): Promise<Stats | BigIntStats>`
- `mkdir(path: string, _options?: { recursive?: boolean; mode?: number; }): Promise<string | undefined>`
- `unlink(path: string): Promise<void>`
- `rename(oldPath: string, newPath: string): Promise<void>`
- `copyFile(src: string, dest: string, _mode?: number): Promise<void>`
- `access(path: string, _mode?: number): Promise<void>`
- `exists(path: string): Promise<boolean>`
- `rm(path: string, options?: { force?: boolean; recursive?: boolean; }): Promise<void>`
- `rmdir(path: string, _options?: { maxRetries?: number; recursive?: boolean; retryDelay?: number; }): Promise<void>`
- `truncate(path: string, _len?: number): Promise<void>`
- `utimes(_path: string, _atime: string | number | Date, _mtime: string | number | Date): Promise<void>`
- `realpath(path: string): Promise<string>`
- `cp(src: string, dest: string, _options?: { recursive?: boolean; }): Promise<void>`
- `mkdtemp(prefix: string): Promise<string>`
- `chmod(_path: string, _mode: string | number): Promise<void>`
- `chown(_path: string, _uid: number, _gid: number): Promise<void>`
- `lchown(_path: string, _uid: number, _gid: number): Promise<void>`
- `lchmod(_path: string, _mode: string | number): Promise<void>`
- `lutimes(_path: string, _atime: string | number | Date, _mtime: string | number | Date): Promise<void>`
- `symlink(_target: string, _path: string, _type?: "dir" | "file" | "junction"): Promise<void>`
- `link(_existingPath: string, _newPath: string): Promise<void>`
- `readlink(_path: string, _options?: { encoding?: BufferEncoding; }): Promise<string>`
- `statfs(path: string, options?: { bigint?: false; }): Promise<StatFs>`
- `statfs(path: string, options: { bigint: true; }): Promise<BigIntStatFs>`
- `statfs(_path: string, _options?: { bigint?: boolean; }): Promise<StatFs | BigIntStatFs>`
- `open(_path: string, _flags?: string | number, _mode?: number): Promise<IFileHandle>`
- `opendir(_path: string, _options?: { encoding?: BufferEncoding; bufferSize?: number; recursive?: boolean; }): Promise<IDir>`
- `createReadStream(_path: string, _options?: { encoding?: BufferEncoding; start?: number; end?: number; }): ReadStream`
- `createWriteStream(_path: string, _options?: { encoding?: BufferEncoding; flags?: string; mode?: number; }): WriteStream`
- `watch(_path: string, _options?: { encoding?: BufferEncoding; persistent?: boolean; recursive?: boolean; }): FSWatcher`

### PathCache

```ts
class PathCache
```

- `constructor(rootFolderId: string): PathCache`
- `get(path: string): string | undefined`
- `set(path: string, id: string): void`
- `invalidate(path: string): void`
- `clear(): void`

### GooglePhotosMediaProvider

```ts
class GooglePhotosMediaProvider
```

- `constructor(accessToken: string): GooglePhotosMediaProvider`
- `listItems(): Promise<MediaItem[]>`
- `getItem(id: string): Promise<MediaItem | null>`
- `createItem(_item: Omit<MediaItem, "id" | "createdAt" | "updatedAt">): Promise<MediaItem>`
- `updateItem(_id: string, _updates: Partial<MediaItem>): Promise<MediaItem>`
- `deleteItem(_id: string): Promise<void>`
- `search(query: string): Promise<MediaItem[]>`
- `getAlbums(): Promise<string[]>`
- `getByAlbum(album: string): Promise<MediaItem[]>`
- `getByDateRange(start: Date, end: Date): Promise<MediaItem[]>`

### GoogleCalendarProvider

```ts
class GoogleCalendarProvider
```

- `constructor(accessToken: string): GoogleCalendarProvider`
- `listItems(): Promise<CalendarEvent[]>`
- `getItem(id: string): Promise<CalendarEvent | null>`
- `createItem(item: Omit<CalendarEvent, "id" | "createdAt" | "updatedAt">): Promise<CalendarEvent>`
- `updateItem(id: string, updates: Partial<CalendarEvent>): Promise<CalendarEvent>`
- `deleteItem(id: string): Promise<void>`
- `search(query: string): Promise<CalendarEvent[]>`
- `getCalendars(): Promise<CalendarInfo[]>`
- `getEventsByRange(start: Date, end: Date): Promise<CalendarEvent[]>`
- `getEventsByCalendar(calendarId: string): Promise<CalendarEvent[]>`

### GoogleContactsProvider

```ts
class GoogleContactsProvider
```

- `constructor(accessToken: string): GoogleContactsProvider`
- `listItems(): Promise<ContactItem[]>`
- `getItem(id: string): Promise<ContactItem | null>`
- `createItem(item: Omit<ContactItem, "id" | "createdAt" | "updatedAt">): Promise<ContactItem>`
- `updateItem(id: string, updates: Partial<ContactItem>): Promise<ContactItem>`
- `deleteItem(id: string): Promise<void>`
- `search(query: string): Promise<ContactItem[]>`
- `getGroups(): Promise<ContactGroup[]>`
- `getByGroup(groupId: string): Promise<ContactItem[]>`
- `searchByName(name: string): Promise<ContactItem[]>`

## Types

### GoogleDriveConfig

```ts
type GoogleDriveConfig = { accessToken?: string; rootFolderId?: string; baseUrl?: string; }
```

### GoogleDriveConfigInput

What a constructor accepts: fields with a schema default may be omitted.

```ts
type GoogleDriveConfigInput = { accessToken?: string; rootFolderId?: string; baseUrl?: string; }
```

## Constants

### GoogleDriveConfigSchema

```ts
const GoogleDriveConfigSchema: z.ZodObject<{ accessToken: z.ZodString; rootFolderId: z.ZodDefault<z.ZodString>; baseUrl: z.ZodDefault<z.ZodString>; }, "strip", z.ZodTypeAny, { accessToken?: string; rootFolderId?: string; baseUrl?: string; }, { accessToken?: string; rootFolderId?: string; baseUrl?: string; }>
```
