@render-lab/tasks-gdrive
v0.3.0
Published
Durable Google Drive tasks for Render Workflows: gdrive.upload/search/export.
Readme
@render-lab/tasks-gdrive
⚠️ Experimental: proof of concept. This package is part of the Render Tasks POC and is published for testing only. It is not fully tested or production ready. Task names, inputs, outputs, and behavior can change or break in any release. Pin exact versions and expect breaking changes.
Durable Google Drive tasks for Render Workflows.
import { upload, search, exportFile } from "@render-lab/tasks-gdrive";| Task | Input | Output |
| --------------------- | ----------------------------------------- | ---------------- |
| gdrive.upload | { name, content, mimeType?, parentId? } | UploadResult |
| gdrive.search | { query, limit? } | DriveFile[] |
| gdrive.export | { fileId, mimeType } | ExportResult |
| gdrive.getFile | { fileId } | DriveFile |
| gdrive.download | { fileId } | DownloadResult |
| gdrive.share | { fileId, role, type, emailAddress? } | ShareResult |
| gdrive.createFolder | { name, parentId? } | DriveFile |
| gdrive.move | { fileId, addParents?, removeParents? } | DriveFile |
| gdrive.copy | { fileId, name? } | DriveFile |
| gdrive.delete | { fileId } | DeleteResult |
All tasks return JSON-serializable DTOs (DriveFile, UploadResult, ExportResult, DownloadResult, ShareResult, DeleteResult) — never raw Google Drive API responses. The default port is fetch-backed against the Drive REST API at https://www.googleapis.com/drive/v3 (uploads go to https://www.googleapis.com/upload/drive/v3/files), authenticated with Authorization: Bearer $GOOGLE_ACCESS_TOKEN.
gdrive.upload defaults mimeType to text/plain and creates a file via a uploadType=multipart request. gdrive.export downloads a Doc/Sheet/Slide converted to the requested text MIME type (e.g. text/markdown, text/plain), whereas gdrive.download fetches a file's raw bytes (alt=media) as text. gdrive.share grants a permission (role + type, plus emailAddress for user/group grants) — the hand-off primitive. gdrive.getFile, gdrive.createFolder, gdrive.move (via addParents/removeParents), and gdrive.copy all return a DriveFile; gdrive.delete permanently removes a file and returns { id, deleted: true }.
Install
pnpm add @render-lab/tasks-gdrive @renderinc/sdk@renderinc/sdk is a peer dependency. The package has no vendor dependency — it uses the global fetch.
Environment contract
Credentials are read lazily at the first API call, never at import (ADR-0007), so importing the package for one task never requires another's secret.
| Variable | Required | Purpose |
| --------------------- | -------- | ----------------------------------------------------------------------- |
| GOOGLE_ACCESS_TOKEN | yes | Google OAuth access token, sent as Authorization: Bearer …. |
OAuth is out of POC scope. These tasks take a pre-issued Google OAuth access token via GOOGLE_ACCESS_TOKEN (with the https://www.googleapis.com/auth/drive scope). Acquiring and refreshing that token — the OAuth consent + refresh flow — is the caller's responsibility and is not implemented here.
Extending & testing
Every operation exports the wrapped task and its raw *Impl. The impls depend on a small DrivePort interface, so they unit-test without touching the network:
import { uploadImpl, type DrivePort } from "@render-lab/tasks-gdrive";
const drive: Partial<DrivePort> = {
upload: async () => ({
id: "file-1",
webViewLink: "https://drive.google.com/file/d/file-1/view",
}),
};
await uploadImpl(
{ name: "brief.txt", content: "hello world" },
{ drive } as any,
);Run the tests with pnpm -C packages/tasks-gdrive test.
