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

@sugiyamalabs/effect-kysely

v0.1.0

Published

Kysely's type-safe query builder, executed by Effect 4's SqlClient (same connection, transactions and tracing).

Readme

@sugiyamalabs/effect-kysely

Kysely's type-safe query builder, executed by Effect 4's SqlClient.

Kysely builds and compiles the query. The SQL and its parameters then run through the SqlClient already in your Effect context, so you keep:

  • one connection pool: whatever SqlClient layer you provide (@effect/sql-pg, @effect/sql-sqlite-bun…);
  • Effect's transactions: queries inside sql.withTransaction(...) roll back with it;
  • Effect's tracing and errors: failures are SqlError, spans come from the client.

@effect/sql-kysely covers Effect 3. This package is for Effect 4.

Install

bun add @sugiyamalabs/effect-kysely kysely effect

Use

import { EffectKysely } from "@sugiyamalabs/effect-kysely"
import { PgClient } from "@effect/sql-pg"
import { Effect, Redacted } from "effect"
import { CamelCasePlugin, type Generated } from "kysely"

interface Database {
  users: { id: Generated<number>; displayName: string; createdAt: Generated<Date> }
}

const db = EffectKysely.make<Database>({ dialect: "postgres", plugins: [new CamelCasePlugin()] })

const program = Effect.gen(function*() {
  const ana = yield* db.executeTakeFirstOrFail(
    db.query.insertInto("users").values({ displayName: "Ana" }).returning(["id", "displayName"])
  )
  //    ^ { id: number; displayName: string }
  return yield* db.execute(db.query.selectFrom("users").selectAll().where("id", "=", ana.id))
})

program.pipe(Effect.provide(PgClient.layer({ url: Redacted.make(process.env.DATABASE_URL!) })))

API

EffectKysely.make<DB>({ dialect, plugins? }) returns:

| | | |---|---| | query | The Kysely instance to build queries with. It never connects. | | execute(q) | Effect<ReadonlyArray<Row>, SqlError, SqlClient> | | executeTakeFirst(q) | First row or undefined | | executeTakeFirstOrFail(q) | First row, or fails with NoSuchElementError | | compile(q) | The compiled { sql, parameters }, without running it |

  • dialect is "postgres" | "sqlite" | "mysql" | "mssql" and must match the SqlClient you provide.
  • q is any Kysely query builder or a sql template.
  • Kysely plugins (like CamelCasePlugin) work as usual, on both the query and the rows. The client's own transformResultNames is skipped for these queries, so the rows always match Kysely's types.

Transactions

const sql = yield* SqlClient.SqlClient
yield* sql.withTransaction(Effect.gen(function*() {
  yield* db.execute(db.query.insertInto("users").values({ displayName: "Bia" }))
  yield* db.execute(db.query.updateTable("counters").set((e) => ({ n: e("n", "+", 1) })))
}))

Limits

  • numAffectedRows and insertId are not returned, because Effect's SqlClient only returns rows. Use returning(...) where your database supports it.
  • Kysely's own execute(), stream() and transaction() don't work on query: run everything through this package and Effect.

Develop

bun install
bun test                                                        # SQLite in memory
PG_URL=postgres://postgres:pw@localhost:5432/postgres bun test  # also against Postgres
bun run check && bun run build

MIT © SugiyamaLabs