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

anbaric-data-store

v1.20.0

Published

Data stores for Anbaric apps: schema-validated JSON documents, encrypted secrets, and a relational (SQL) store, backed in memory / SQLite locally or by the Anbaric Cloud

Readme

anbaric-data-store

Schema-validated JSON document storage, secret storage, and a relational (SQL) store for Anbaric apps, with local implementations and env-driven factories. App developers usually install anbaric, which re-exports this package.

Documents

import {JsonStoreFactory} from "anbaric-data-store";
import type {Actor} from "anbaric-tsapi";

const customers = JsonStoreFactory.instance("customers", {
    type: "object",
    required: ["name"],
    properties: { name: { type: "string" }, email: { type: "string" } },
});

// Every store call records the acting actor for the audit trail.
const actor : Actor = { type: "CODE", id: "seed-script", role: "admin" };

await customers.create(actor, "ada", { name: "Ada", email: "[email protected]" });
await customers.save(actor, "corrected email", "ada", { name: "Ada", email: "[email protected]" });
const ada = await customers.retrieve("ada", actor);   // throws No document found with id "x" when absent
const all = await customers.list(actor);              // returns document values, not ids
await customers.delete("ada", actor);

The first argument is the collection name; collections are independent. The optional second argument is a JsonSchema (subset: type, properties, required, items, enum) — documents failing it are rejected on create/save with a failed schema validation error before anything is stored.

Secrets

import {SecretStoreFactory} from "anbaric-data-store";

const secrets = SecretStoreFactory.instance();
await secrets.create(actor, "api-key", "s3cr3t");
const key = await secrets.retrieve("api-key", actor);

SQL

A relational store for structured app data. Locally it is backed by SQLite (an in-memory database by default); once deployed, every app in a tenant shares one dedicated PostgreSQL schema (anbaric_app_data), kept apart from the platform's own schemas by a scoped database role.

import {SqlStoreFactory} from "anbaric-data-store";

const sql = SqlStoreFactory.instance();

await sql.execute(actor, "CREATE TABLE IF NOT EXISTS notes (id SERIAL PRIMARY KEY, body TEXT)");
await sql.execute(actor, "INSERT INTO notes (body) VALUES ($1)", ["hello"]);   // SQLite: VALUES (?)
const rows = await sql.query(actor, "SELECT id, body FROM notes WHERE body = $1", ["hello"]);

query returns the rows; execute returns the number of affected rows. Both record the interaction (QUERY / EXECUTE) for the audit trail.

SQLite (local) vs PostgreSQL (cloud). The backends are close but not identical — write portable SQL, or target the one you deploy to:

| | SQLite (local) | PostgreSQL (cloud) | | --- | --- | --- | | Parameter placeholders | positional ? | numbered $1, $2 | | Auto-increment key | INTEGER PRIMARY KEY | SERIAL / GENERATED … AS IDENTITY | | Column types | dynamic (TEXT/INTEGER/REAL/BLOB) | static and rich (JSONB, TIMESTAMPTZ, …) | | Booleans | 0 / 1 | native boolean | | Persistence | in-memory unless ANBARIC_SQL_FILE is set | durable, shared across the tenant's apps |

Factories

| Factory | Env var | Default | cloud | | --- | --- | --- | --- | | JsonStoreFactory.instance(collection, schema?) | ANBARIC_JSON_STORE_TYPE | InMemoryJsonStore | CloudJsonStore | | SecretStoreFactory.instance() | ANBARIC_SECRET_STORE_TYPE | InMemorySecretStore | CloudSecretStore | | SqlStoreFactory.instance() | ANBARIC_SQL_STORE_TYPE | SqliteSqlStore | PostgresSqlStore |

An Anbaric platform injects cloud into deployed apps automatically. In cloud mode documents live in the platform's Postgres and secrets in its secret store (AWS Secrets Manager on the hosted platform); the SQL store connects directly to the tenant's Postgres, in its own anbaric_app_data schema.