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

@storic/core

v0.4.0

Published

The core implementation of Storic - a schema-versioned datastore with automatic lens-based transformations.

Readme

@storic/core

The core implementation of Storic - a schema-versioned datastore with automatic lens-based transformations.

Overview

@storic/core provides a flexible datastore that allows you to:

  • Version schemas using content-addressable hashing (SHA256)
  • Store entities under specific schema versions
  • Define bidirectional lenses to transform data between schema versions
  • Query entities with automatic projection to any reachable schema version
  • Index data using SQLite's JSON expression syntax

Installation

bun add @storic/core

Core Concepts

Store

The Store service provides the main API for interacting with your data. It manages schemas, entities, and lenses.

Schemas

Schemas are defined using Effect Schema syntax and are automatically versioned by hashing their definition. Each schema gets a unique ID that represents its exact structure.

Lenses

Lenses define bidirectional transformations between schema versions. They consist of:

  • forward: Transform from version A to version B
  • backward: Transform from version B to version A

Lenses are composable - the store automatically finds transformation paths between any two connected schema versions.

JsEvaluator

An abstraction over JavaScript expression evaluation. The default implementation uses new Function(), but can be swapped with alternative implementations (like @storic/cloudflare for sandboxed evaluation).

Quick Start

import { Console, Effect, Layer } from "effect";
import { BunRuntime } from "@effect/platform-bun";
import { layer as sqliteLayer } from "@effect/sql-sqlite-bun/SqliteClient";
import { Store, JsEvaluator } from "@storic/core";

// Setup layers
const SqlLive = sqliteLayer({ filename: ":memory:" });
const StoreLive = Store.layer.pipe(Layer.provide(Layer.mergeAll(SqlLive, JsEvaluator.Eval)));

// Use the store
const program = Effect.gen(function* () {
  const store = yield* Store;

  // Register a schema
  const userV1 = yield* store.registerSchema(
    "User",
    `S.Struct({ firstName: S.String, lastName: S.String, email: S.String })`,
  );

  // Create an entity
  const alice = yield* store.createEntity(userV1.id, {
    firstName: "Alice",
    lastName: "Smith",
    email: "[email protected]",
  });

  // Read it back
  const entity = yield* store.getEntity(alice.id);
  yield* Console.log(entity.data);
});

BunRuntime.runMain(Effect.provide(program, StoreLive));

API Reference

Store Methods

Schema Management

  • registerSchema(name: string, def: string) - Register a new schema version
  • getSchema(id: string) - Retrieve a schema by ID
  • listSchemas(name?: string) - List all schemas, optionally filtered by name

Entity Management

  • createEntity(schemaId: string, data: unknown, options?) - Create a new entity
  • getEntity(id: string, options?) - Get an entity, optionally projecting to a different schema
  • listEntities(schemaId: string, options?) - List entities, optionally with projection
  • updateEntity(id: string, data: unknown, options?) - Update an entity (merge or replace)
  • deleteEntity(id: string) - Delete an entity

Lens Management

  • registerLens(options) - Register a bidirectional lens between two schemas
  • getLens(from: string, to: string) - Retrieve a specific lens
  • listLenses(schemaId?: string) - List all lenses, optionally filtered by schema

Indexing

  • createIndex(name: string, expression: string) - Create a SQLite JSON expression index
  • dropIndex(name: string) - Drop an index
  • listIndexes() - List all indexes

Effect Integration

@storic/core is built on Effect, providing:

  • Type-safe error handling with discriminated error types
  • Composable service layers for dependency injection
  • Structured concurrency and resource management
  • First-class support for Effect's ecosystem

Error Types

All operations return Effect types with specific error types:

  • SchemaNotFoundError - Schema ID doesn't exist
  • EntityNotFoundError - Entity ID doesn't exist
  • ValidationError - Data doesn't match schema
  • LensPathNotFoundError - No transformation path exists between schemas
  • SchemaDefEvalError - Schema definition evaluation failed
  • TransformError - Lens transformation failed

License

MIT