Skip to content

feat: add GoogleDriveTransport for uploading docx as Google Docs#12

Merged
llbbl merged 1 commit into
mainfrom
feat/google-drive-transport
Jul 26, 2026
Merged

feat: add GoogleDriveTransport for uploading docx as Google Docs#12
llbbl merged 1 commit into
mainfrom
feat/google-drive-transport

Conversation

@llbbl

@llbbl llbbl commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds GoogleDriveTransport, a Transport implementation that uploads a .docx buffer to Google Drive and converts it into a native Google Doc on import.
  • Keeps the SDK footprint minimal for consumers who never touch Drive.

Changes

Features

  • src/google.ts: New GoogleDriveTransport using the Drive v3 API's files.create/files.update, with the .docx bytes as the media body and mimeType: application/vnd.google-apps.document so Drive converts the file on upload; the returned fileId is stored.
  • src/google.ts: Scoped to the drive.file scope only; access-token acquisition is left to the consumer rather than baked into the transport.
  • src/google.ts: @googleapis/drive is imported lazily so consumers who never touch Google Drive don't pay for loading the SDK.
  • package.json: Adds google-auth-library as an optional peer dependency.

Refactoring

  • src/transport.ts: DOCX_MIME_TYPE relocated here from src/sharepoint.ts.
  • src/sharepoint.ts: Re-exports DOCX_MIME_TYPE from src/transport.ts, keeping the public API surface unchanged while letting both transports share the constant.
  • src/index.ts: Wires up the new GoogleDriveTransport export.

Tests

  • tests/index.test.ts: Mocked Google client tests covering the .docx upload/convert flow and asserting the drive.file scope.
  • vitest.config.ts: Config updates to support the new test file.

Documentation

  • README.md: Documents GoogleDriveTransport usage.

Test plan

  • pnpm check (biome + tsc + 162 vitest tests + build) passes
  • js-ts-code-reviewer PASS

Closes #5

Adds a Transport implementation that uploads a .docx buffer to Google
Drive and converts it into a native Google Doc on import.

### Features
- `GoogleDriveTransport` in `src/google.ts` uses the Drive v3 API's
  `files.create`/`files.update` with the `.docx` bytes as the media
  body and `mimeType: application/vnd.google-apps.document`, so Drive
  performs the conversion on upload; the returned `fileId` is stored.
- Scoped to `drive.file` only; access-token acquisition is left to the
  consumer rather than baked into the transport.
- `@googleapis/drive` is imported lazily so consumers who never touch
  Google Drive don't pay for loading the SDK.
- `google-auth-library` is declared as an optional peer dependency.

### Refactoring
- `DOCX_MIME_TYPE` moves to `src/transport.ts` and is re-exported from
  `src/sharepoint.ts`, keeping the public API surface unchanged while
  letting both transports share the constant.

Closes #5
@llbbl
llbbl merged commit cc308e0 into main Jul 26, 2026
4 checks passed
@llbbl
llbbl deleted the feat/google-drive-transport branch July 26, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GoogleDriveTransport (extract from polydoc)

1 participant