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

@sf-ai/sdk

v0.2.1

Published

Type-safe SDK for the San Francisco database with GraphQL codegen

Readme

@sf-ai/sdk

Type-safe SDK for the San Francisco database with GraphQL codegen.

Overview

This package provides a type-safe SDK generated from the San Francisco RAG database schema using @constructive-io/graphql-codegen. It generates both React Query hooks and a Prisma-like ORM client from the PGPM modules.

Installation

pnpm add @sf-ai/sdk

Usage

ORM Client

import { createClient } from '@sf-ai/sdk';

const db = createClient({
  endpoint: process.env.GRAPHQL_ENDPOINT,
  headers: {
    Authorization: `Bearer ${process.env.API_TOKEN}`,
  },
});

// Query documents
const documents = await db.document.findMany({
  select: { id: true, title: true, content: true },
  first: 10,
}).execute().unwrap();

// Query chunks with embeddings
const chunks = await db.chunk.findMany({
  select: {
    id: true,
    content: true,
    document: { select: { id: true, title: true } },
  },
}).execute().unwrap();

React Query Hooks

import { useDocumentsQuery, useChunksQuery } from '@sf-ai/sdk';

function DocumentList() {
  const { data, isLoading } = useDocumentsQuery({ first: 10 });

  if (isLoading) return <div>Loading...</div>;

  return (
    <ul>
      {data?.documents.nodes.map((doc) => (
        <li key={doc.id}>{doc.title}</li>
      ))}
    </ul>
  );
}

Regenerating the SDK

The SDK is generated from the PGPM modules in this repository. To regenerate:

Locally

Requires a running PostgreSQL database with the schema deployed:

cd packages/sf-sdk
pnpm run codegen:all

Via GitHub Actions

Use the "Generate SDK" workflow which:

  1. Spins up an ephemeral PostgreSQL database
  2. Deploys the PGPM modules
  3. Generates the SDK types
  4. Optionally commits the changes

Run the workflow from the Actions tab with the "commit_changes" option enabled to automatically commit regenerated types.

Configuration

The codegen configuration is in graphql-codegen.config.ts:

import { defineConfig } from '@constructive-io/graphql-codegen';

export default defineConfig({
  targets: {
    default: {
      db: {
        pgpm: {
          modulePath: '../rag-core',
        },
        schemas: ['rag'],
      },
      output: './src/generated',
      // ... other options
    },
  },
});

Schema

The SDK is generated from the rag schema which includes:

  • embedding_model - Embedding model configurations
  • collection - Document collections
  • collection_model - Collection-model associations
  • document - Full documents
  • chunk - Document chunks for RAG
  • embedding - Vector embeddings

License

SF License