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

@emulates/notion

v0.1.1

Published

Notion 2022-06-28 OAuth, database search and page creation emulator.

Readme

@emulates/notion

Part of Emulates: high-fidelity, in-process emulators for APIs and databases.

WIP Notion 2022-06-28 database search, OAuth token exchange and database-parent page creation. This is the legacy database API, not the newer data-source API.

Install

bun add @emulates/notion

Usage

import { createRuntime } from "@emulates/notion"

const notion = createRuntime()
const result = await notion.fetch(new Request("http://notion.test/v1/search", {
  method: "POST",
  headers: {
    authorization: "Bearer mock_notion_token",
    "notion-version": "2022-06-28",
    "content-type": "application/json",
  },
  body: JSON.stringify({ filter: { property: "object", value: "database" }, page_size: 100 }),
}))
const { results } = await result.json()
console.log(results[0].properties)

Run emulates-notion serve --port 12127 and inject http://localhost:12127 as the consumer's API origin. Keep /v1 in request paths. No universal vendor environment variable exists for this origin override. The reported integration uses raw fetch.

Contract

  • POST /v1/oauth/token: HTTP Basic client credentials and a JSON authorization-code grant. Constructor/admin-seeded codes bind a client, redirect URI and workspace grant. Codes are single-use; successful exchange returns token, bot and workspace metadata.
  • POST /v1/search: Bearer grant plus Notion-Version: 2022-06-28. Returns legacy page_or_database lists with database ids/properties, query filtering, page_size, start_cursor, next_cursor and has_more. Results are limited to the granted workspace and database ids. Fixture insertion order is stable; relevance ranking is not modelled.
  • POST /v1/pages: database_id parent and properties addressed by name or id. Successful writes return 200 with a page UUID and retain the parent/properties. Unknown or inaccessible parents return 404; read-only grants return 403. Unknown properties and wrong value types return 400 without partial writes.

The default fixture is one synthetic survey database (Name/title, Score/number) with mock_notion_token. Configure databases, grants, clients and codes for other workspaces and OAuth scenarios. No authorization browser or webhooks are required by this subset.

Controls

Shared /__admin/state/{databases,grants,clients,codes,pages} surfaces seed and inspect records. Reset restores constructor fixtures and clears created pages. Shared Timeline, clock, journal and fault APIs apply; logs do not contain page contents or credentials. Use only synthetic data. Namespaces are selected by header, /__admin/ns/{name} prefix or mapped bearer tokens. Set adminPrefix to relocate controls.

Presets: unauthorized, rate_limited (429, Retry-After), server_error (503) and connection_drop. Shared fault rules support latency and one-shot failures.

Acceptance tests cover issue #284 through raw fetch, OAuth binding/replay, schema errors, pagination, isolation/reset, journal redaction and served HTTP. Property tests exercise all three operations and detect divergence. bun scripts/parity.ts requires NOTION_API_KEY; it only checks a pinned-version empty search, never creating real pages. Live parity has not run. The official SDK v2.2.15 types provide the archived wire-contract evidence.

Deliberately not modelled

New data-source APIs, full rich-text rendering/mentions, blocks, database editing/querying, page-parent creation, relevance sorting, full page/database response metadata, formulas, rollups, select-option creation, relationship resolution and full vendor field constraints. Property validation checks the requested schema's value kind: title/text, number, checkbox, nullable strings/dates, select/status/multi-select, people/relation ids and file objects. It does not emulate every Notion property limit or expand typed request values to full response objects. Only the pinned API version is accepted.

API

  • NotionAPI: FetchAPI with fetch, reset and database/grant/client/code/page collections.
  • createRuntime: shared admin, namespace, clock, faults and journal contract.
  • NOTION_NAMESPACE: service name.
  • NOTION_PRESETS: deterministic fault presets.
  • DEFAULT_DATABASES: synthetic survey schema.
  • document, operationIds, supportedOperationIds: generated OpenAPI metadata.
  • createServer, serveTarget, DEFAULT_PORT from ./server: Node HTTP/CLI target (default port 12127).

Public types: Property, Database, Grant, OAuthCode, Client, Page, NotionAPIOptions, OperationId, SupportedOperationId.