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

@weaveintel/notes

v0.1.2

Published

Structured notes as a capability — a NoteRepository port, contract test, and doc model.

Readme

@weaveintel/notes

The slim, brand-free seam in front of notes: one NoteRepository port, a shared contract test, an in-memory adapter, and pure helpers for the note-document model.

Why it exists

If every part of an app reaches into note storage on its own — one place saving from an HTTP route, another overwriting the whole document on every keystroke — two tabs or two people quietly clobber each other's work. The fix is to make storage go through a single doorway with agreed-upon rules, the way a library has one checkout desk instead of letting everyone shelve books themselves. This package is that doorway: a NoteRepository interface plus a contract test that pins every implementation to identical behaviour, so the app can swap an in-memory store for a SQL one — or a real-time co-editing engine — without changing a line of calling code. Product features (the editor UI, AI actions) live in the app; this layer stays small and portable.

When to reach for it

Reach for it when you're implementing note storage or a feature that reads/writes notes: use the port so your code doesn't hard-wire a database, and run noteRepositoryContract against any adapter you build. Reach for the pure helpers to parse wiki-links, resolve entities, or convert between the block-document model and its doc_json form. If you want the finished notes application — routes, editor, AI — that lives in apps/geneweave, not here; this package is the reusable contract underneath it.

How to use it

import { createInMemoryNoteRepository } from '@weaveintel/notes';

const repo = createInMemoryNoteRepository();

const note = await repo.create({
  ownerId: 'user-1',
  title: 'Launch plan',
  doc_json: { type: 'doc', content: [] },
});

const patched = await repo.update(note.id, { title: 'Launch plan (v2)' });
console.log(patched?.title); // → "Launch plan (v2)"

Store it in a real database (Postgres)

The in-memory adapter is perfect for tests, but your notes need to survive a restart. createPostgresNoteRepository is the same doorway (NoteRepository) backed by Postgres — so you swap it in and nothing else changes. You hand it a pg.Pool (share one across your whole app — e.g. the pool from weaveSharedPostgres in @weaveintel/persistence), and it creates its tables on first use. No migration step to run first.

import pg from 'pg';
import { createPostgresNoteRepository } from '@weaveintel/notes';

const repo = createPostgresNoteRepository({ pool: new pg.Pool({ connectionString: process.env.DATABASE_URL }) });

await repo.createNote({ id: 'n1', owner_user_id: 'u1', title: 'Launch plan' });
const note = await repo.getNote('n1', 'u1');
const mine = await repo.listNotes('u1', { search: 'launch', favorite: true });

How do you know it behaves exactly like the in-memory version? The same contract test runs against both:

import { noteRepositoryContract, createPostgresNoteRepository } from '@weaveintel/notes';
noteRepositoryContract(() => createPostgresNoteRepository({ pool }), { describe, it, beforeEach, expect });

Safe by construction: every title, note body, and search term is a bound parameter, so hostile content that tries to smuggle SQL commands (stray quotes, semicolons, comment markers) is stored as harmless text, never executed. Owner-scoping (you only see your own notes), the favourite-then-recent ordering, search-matches-title-or-body, and one-level cascade delete all behave identically to the reference. Proven on a real Postgres against a 2,000-note workspace — and end-to-end with an AI writing a note that's then stored and found by search.

What's in the box

  • The port & adaptersNoteRepository (interface), createInMemoryNoteRepository (tests), and createPostgresNoteRepository (durable), plus input/patch types (CreateNoteInput, UpdateNotePatch, NoteListFilter, …).
  • Contract testnoteRepositoryContract: run it against any adapter to prove identical behaviour.
  • Content extractionextractPlainText, extractTaskItems.
  • Wiki-links & entitiesparseWikiLinks, findUnlinkedMentions, buildLinkSuggestions, resolveEntities, canonicalizeEntityName.
  • Note-document modelblocksToDoc/docToBlocks, blocksPlainText, emptyNoteDoc, NOTE_NODE_REGISTRY.
  • DatabasesparseSchema, validateRow, computeRollup for typed note properties.
  • InkstrokesToSvg, strokeToPath, validateStrokes (freehand strokes → SVG).
  • ExportexportNote, noteToMarkdown, noteToHtmlDocument, noteToWordHtml, noteToJson.
  • Image provenancebuildImageProvenance, embedXmpInSvg, parseProvenanceFromSvg.

License

MIT.