npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@drivebase/sdk

v1.0.0

Published

TypeScript SDK for the Drivebase API

Downloads

9

Readme

@drivebase/sdk

TypeScript SDK for the Drivebase API.

@drivebase/sdk provides a typed client for common file and folder operations over Drivebase GraphQL + REST endpoints, including uploads, downloads, search, and metadata actions.

Features

  • Typed DrivebaseClient for browser and server usage
  • File operations: list, get, contents, search, smart search, upload, download, rename, move, delete, star/unstar
  • Folder operations: list, get, create, rename, move, delete, star/unstar
  • Built-in upload strategies:
    • Simple upload for smaller files
    • Chunked upload for larger files
  • Typed error classes for API, auth, network, and upload failures
  • ESM + CJS builds with TypeScript declarations

Installation

bun add @drivebase/sdk

Or with npm:

npm install @drivebase/sdk

Quick Start

import { DrivebaseClient } from "@drivebase/sdk";

const client = new DrivebaseClient({
  apiKey: process.env.DRIVEBASE_API_KEY!,
  workspaceId: process.env.DRIVEBASE_WORKSPACE_ID!,
  baseUrl: "https://your-drivebase-instance.com",
});

const files = await client.files.list({ limit: 20 });
console.log(files.total, files.files);

Configuration

DrivebaseClient options:

  • apiKey (required): Drivebase API key (Bearer token)
  • workspaceId (required): Workspace to operate in (sent as x-workspace-id)
  • baseUrl (optional): Base URL of your Drivebase API (default: http://localhost:4000)
  • fetch (optional): Custom fetch implementation

If baseUrl ends with /graphql, it is normalized automatically.

API

Files Resource

client.files methods:

  • get(id)
  • list({ folderId?, limit?, offset? })
  • contents({ folderId?, providerIds? })
  • search(query, limit?)
  • smartSearch(query, limit?)
  • recent({ limit? })
  • starred()
  • upload(options, onProgress?)
  • download(id)
  • rename(id, name)
  • move(id, folderId?)
  • delete(id)
  • star(id)
  • unstar(id)

Folders Resource

client.folders methods:

  • get(id)
  • list({ parentId?, providerIds? })
  • starred()
  • create({ name, providerId, parentId? })
  • rename(id, name)
  • move(id, parentId?)
  • delete(id)
  • star(id)
  • unstar(id)

Uploads

Use client.files.upload(...) with progress reporting:

const file = await client.files.upload(
  {
    data: someBlobOrArrayBuffer,
    name: "report.pdf",
    mimeType: "application/pdf",
    size: someBlobOrArrayBuffer.byteLength ?? someBlobOrArrayBuffer.size,
    providerId: "provider_123",
    folderId: "folder_456", // optional
  },
  (progress) => {
    console.log(progress.phase, progress.percent);
  },
);

progress.phase values:

  • uploading
  • transferring
  • complete

Downloads

client.files.download(id) returns:

  • url: direct provider URL when available, otherwise Drivebase proxy URL
  • stream(): lazy function returning ReadableStream<Uint8Array>

Example:

const download = await client.files.download("file_123");
const stream = await download.stream();

Error Handling

The SDK throws typed errors:

  • DrivebaseError (base class)
  • ApiError (GraphQL/API-level failures)
  • AuthenticationError (401 / invalid credentials)
  • NetworkError (connection/transport errors)
  • UploadError (upload-specific failures)

Example:

import {
  ApiError,
  AuthenticationError,
  DrivebaseError,
  NetworkError,
  UploadError,
} from "@drivebase/sdk";

try {
  await client.files.list();
} catch (error) {
  if (error instanceof AuthenticationError) {
    // invalid apiKey or workspace access
  } else if (error instanceof ApiError) {
    console.error(error.errors);
  } else if (error instanceof UploadError) {
    console.error(error.sessionId);
  } else if (error instanceof NetworkError) {
    console.error(error.message);
  } else if (error instanceof DrivebaseError) {
    console.error(error.code, error.message);
  }
}

Development

From the repository root:

bun run --filter @drivebase/sdk build
bun run --filter @drivebase/sdk check-types

SDK tests:

bun test packages/sdk/tests

License

MIT