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

@proseql/node

v0.10.7

Published

Node.js file system adapter for ProseQL, re-exports core plus NodeStorageLayer

Readme

@proseql/node

Node.js file persistence for ProseQL. Re-exports everything from @proseql/core plus filesystem storage adapters.

Install

npm install @proseql/node

Quick Start

import { Effect, Schema } from "effect"
import { createNodeDatabase } from "@proseql/node"

const BookSchema = Schema.Struct({
  id: Schema.String,
  title: Schema.String,
  author: Schema.String,
  year: Schema.Number,
})

const config = {
  books: {
    schema: BookSchema,
    file: "./data/books.yaml",
    relationships: {},
  },
} as const

const program = Effect.gen(function* () {
  const db = yield* createNodeDatabase(config)

  yield* db.books.create({ title: "Dune", author: "Frank Herbert", year: 1965 })
  // → saved to ./data/books.yaml

  const classics = yield* Effect.promise(
    () => db.books.query({ where: { year: { $lt: 1970 } } }).runPromise
  )
})

await Effect.runPromise(Effect.scoped(program))

For the full query and mutation API, see @proseql/core.

Persistence Approaches

Three ways to set up file persistence, from simplest to most configurable.

A. createNodeDatabase (Zero-Config)

Codecs are inferred from file extensions. No manual layer wiring needed.

import { Effect } from "effect"
import { createNodeDatabase } from "@proseql/node"

const program = Effect.gen(function* () {
  const db = yield* createNodeDatabase(config, initialData, {
    writeDebounce: 50,  // optional: debounce writes (ms)
  })

  yield* db.books.create({ title: "Neuromancer", author: "William Gibson", year: 1984 })
  // → triggers debounced write to ./data/books.yaml
})

await Effect.runPromise(Effect.scoped(program))

B. makeNodePersistenceLayer (Explicit Layer)

Builds a Layer from your config. Use when composing with other layers or passing extra codecs.

import { Effect } from "effect"
import {
  createPersistentEffectDatabase,
  makeNodePersistenceLayer,
} from "@proseql/node"

const PersistenceLayer = makeNodePersistenceLayer(config)

const program = Effect.gen(function* () {
  const db = yield* createPersistentEffectDatabase(config, initialData)
  // ...
})

await Effect.runPromise(
  program.pipe(Effect.provide(PersistenceLayer), Effect.scoped)
)

C. Manual Layer.merge (Full Control)

Wire NodeStorageLayer and makeSerializerLayer by hand. Use for custom codec options, plugin codecs, or non-standard setups.

import { Effect, Layer } from "effect"
import {
  createPersistentEffectDatabase,
  NodeStorageLayer,
  makeSerializerLayer,
  jsonCodec,
  yamlCodec,
} from "@proseql/node"

const ManualLayer = Layer.merge(
  NodeStorageLayer,
  makeSerializerLayer([jsonCodec(), yamlCodec()])
)

const program = Effect.gen(function* () {
  const db = yield* createPersistentEffectDatabase(config, initialData)
  // ...
})

await Effect.runPromise(
  program.pipe(Effect.provide(ManualLayer), Effect.scoped)
)

File Formats

Codecs are inferred from file extensions. Mix formats across collections.

| Format | Extension | Description | |--------|-----------|-------------| | JSON | .json | The classic | | JSONL | .jsonl | One object per line, streaming-friendly | | YAML | .yaml | For humans who hate braces | | JSON5 | .json5 | JSON with comments and trailing commas | | JSONC | .jsonc | JSON with comments (VS Code style) | | TOML | .toml | Config-brained perfection | | TOON | .toon | Compact and LLM-friendly | | Hjson | .hjson | JSON for people who make typos | | Prose | .prose | Data that reads like a sentence |

const config = {
  books: { schema: BookSchema, file: "./data/books.yaml", relationships: {} },
  authors: { schema: AuthorSchema, file: "./data/authors.json", relationships: {} },
  events: { schema: EventSchema, file: "./data/events.jsonl", relationships: {} },
} as const

Prose Format

Prose files are self-describing. The @prose directive contains the template:

@prose [{id}] "{title}" by {author} ({year}) — {genre}

[1] "Dune" by Frank Herbert (1965) — sci-fi
[2] "Neuromancer" by William Gibson (1984) — sci-fi

The codec learns the template from the file automatically. For explicit control:

import { proseCodec, makeSerializerLayer } from "@proseql/node"

// explicit template
proseCodec({ template: '[{id}] "{title}" by {author} ({year}) — {genre}' })

// or let it learn from the @prose directive
proseCodec()

Format Override

When prose data lives inside a file with a non-prose extension:

const config = {
  catalog: {
    schema: CatalogSchema,
    file: "./docs/catalog.md",
    format: "prose",  // ← use prose codec, not markdown
    relationships: {},
  },
} as const

Append-Only Collections

For event logs, audit trails, and write-once data. Each create() appends a single JSONL line instead of rewriting the file.

const config = {
  events: {
    schema: EventSchema,
    file: "./data/events.jsonl",
    appendOnly: true,  // ← the magic flag
    relationships: {},
  },
} as const
// these work normally
await db.events.create({ type: "click", target: "button-1" }).runPromise
await db.events.query({ where: { type: "click" } }).runPromise
await db.events.findById("evt_001").runPromise
await db.events.aggregate({ count: true }).runPromise

// these throw OperationError — append-only means append-only
await db.events.update("evt_001", { type: "tap" }).runPromise  // OperationError
await db.events.delete("evt_001").runPromise                    // OperationError

Debounced Writes

Mutations trigger debounced writes. Rapid changes batch into fewer I/O operations.

const db = yield* createNodeDatabase(config, initialData, {
  writeDebounce: 100,  // 100ms debounce
})

flush()

Force all pending writes to disk immediately:

await db.flush()
console.log(`Pending writes: ${db.pendingCount()}`)  // → 0

Node Storage Layer

The NodeStorageLayer provides atomic writes (temp file + rename) with retry and exponential backoff.

import { makeNodeStorageLayer, NodeStorageLayer } from "@proseql/node"

// default configuration
NodeStorageLayer

// custom configuration
const CustomStorageLayer = makeNodeStorageLayer({
  maxRetries: 3,
  baseDelay: 100,
  createMissingDirectories: true,
  fileMode: 0o644,
  dirMode: 0o755,
})

API Reference

Exports from @proseql/node

Everything from @proseql/core is re-exported, plus:

| Export | Description | |--------|-------------| | createNodeDatabase | Zero-config convenience wrapper | | makeNodePersistenceLayer | Build persistence layer from config | | NodeStorageLayer | Default filesystem storage layer | | makeNodeStorageLayer | Create storage layer with custom config |

Types

import type { NodeAdapterConfig } from "@proseql/node"

interface NodeAdapterConfig {
  readonly maxRetries?: number       // default: 3
  readonly baseDelay?: number        // default: 100ms
  readonly createMissingDirectories?: boolean  // default: true
  readonly fileMode?: number         // default: 0o644
  readonly dirMode?: number          // default: 0o755
}

License

MIT