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

@otter-sh/core

v0.1.0

Published

Shared types, config loader, compiler, DAG runner, selector engine, and state store for [Otter](https://github.com/tomnagengast/otter) — a Bun-native ELT tool with `.sql` models and a TypeScript config. Every other `@otter-sh/*` package depends on this on

Readme

@otter-sh/core

Shared types, config loader, compiler, DAG runner, selector engine, and state store for Otter — a Bun-native ELT tool with .sql models and a TypeScript config. Every other @otter-sh/* package depends on this one and it has no runtime dependencies outside Bun built-ins (Bun.sql, bun:sqlite, Bun.file).

Most users do not import @otter-sh/core directly — they install @otter-sh/cli and write an otter.config.ts. Import this package when you are authoring a source driver, target adapter, or a programmatic runner that drives compile / build from code.

Install

bun add @otter-sh/core

Requires Bun — this package imports "bun" and "bun:sqlite" at runtime.

What's exported

  • ConfigdefineConfig, loadConfig, Config, ProfileConfig.
  • Source authoringdefineSource, Source, ExtractOpts, ExtractStream, Row, CursorState, WriteDisposition, IncrementalConfig.
  • Adapter authoringAdapter, LoadStrategy, TableRef, MergeIncrementalOpts, NotSupportedError.
  • Compile / runcompileProject, buildDag, toposort, runBuild, runModelTests, readManifest, writeManifest, writeCompiledSql, Manifest, Dag, DagNode, ColumnConfig, ColumnTest.
  • SelectorsparseSelector, evaluateSelector.
  • StateopenState, StateStore, incrementalPredicate, nextCursor.
  • EventsOtterEmitter, jsonlAppender, NodeEvent.
  • SeedsdiscoverSeeds, loadSeeds, parseCsv.

Using defineConfig

// otter.config.ts
import { postgresAdapter } from "@otter-sh/adapter-postgres";
import { defineConfig } from "@otter-sh/core";
import { postgresSource } from "@otter-sh/source-postgres";

export default defineConfig({
  profiles: {
    dev: {
      target: postgresAdapter({
        url: process.env.PG_URL ?? "postgres://localhost:5432/dev",
        schema: "analytics",
      }),
    },
  },
  sources: {
    stripe_pg: postgresSource({ url: process.env.STRIPE_PG_URL ?? "" }),
  },
  modelsDir: "models",
});

defineConfig is a type-only identity helper — it anchors inference on the Config type.

Writing a source driver

A source driver is any package that exports a typed factory returning a Source. The factory is imported explicitly from otter.config.ts:

import type { Source, ExtractStream, CursorState, ExtractOpts } from "@otter-sh/core";

export interface MySourceOptions {
  url: string;
}

export function mySource(options: MySourceOptions): Source {
  return {
    kind: "my-thing",
    async extract(stream, state, opts): Promise<ExtractStream> {
      // Return { columnTypes, rows: AsyncIterable<Row[]> }.
    },
    async close() {},
  };
}

Writing a target adapter

A target adapter is any package that exports a typed factory returning an Adapter:

import type { Adapter, TableRef, LoadStrategy, Row } from "@otter-sh/core";

export interface MyAdapterOptions {
  url: string;
  schema?: string;
}

export function myAdapter(options: MyAdapterOptions): Adapter {
  const schema = options.schema ?? "public";
  return {
    kind: "my-db",
    schema,
    async introspect() {
      /* ... */
    },
    async bulkLoad(target, rows, strategy, opts) {
      /* ... */
    },
    async execute(sql) {
      /* ... */
    },
    async swap(staging, final) {
      /* ... */
    },
    async close() {},
  };
}

Implement mergeIncremental to support materialized: "incremental" models; leave it undefined to raise NotSupportedError instead.

Declaring source streams

defineSource describes per-stream write dispositions and incremental cursors. The CLI reads these from sourcesDir/<name>.ts:

// sources/stripe_pg.ts
import { defineSource } from "@otter-sh/core";

export default defineSource({
  streams: {
    users: {
      write_disposition: "merge",
      primary_key: "id",
      incremental: { cursor_field: "updated_at" },
    },
  },
});

Full documentation

License

MIT