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

@fuguejs/document-source

v0.5.1

Published

The provider-neutral **document-source capability port**. Defines the `DocumentSource` capability (registry key `documents`), the `FileRef` addressing ADT, `FileMeta`, the test fake, and the shared `unsupportedRefError`. Backend adapters depend on this pa

Readme

@fuguejs/document-source

The provider-neutral document-source capability port. Defines the DocumentSource capability (registry key documents), the FileRef addressing ADT, FileMeta, the test fake, and the shared unsupportedRefError. Backend adapters depend on this package and implement DocumentSource for one store.

The port

interface DocumentSource {
  getContent(ref: FileRef, opts?: { signal?: AbortSignal }): Promise<Result<Uint8Array, FrameworkError>>;
  getMetadata(ref: FileRef, opts?: { signal?: AbortSignal }): Promise<Result<FileMeta, FrameworkError>>;
}

Holds only content + metadata reads, by design. Provider-specific operations (listing, revisions, upload, search) belong on a separate capability, never on this port (see ADR-0052).

FileRef

Discriminated union; illegal/half-specified refs are unrepresentable. New backends add a variant additively.

type FileRef =
  | { kind: "sharePointPath"; siteHostname; sitePath; filePath }
  | { kind: "driveItem"; driveId; itemId }
  | { kind: "shareUrl"; url }
  | { kind: "localPath"; path };

Constructors: sharePointPathRef, driveItemRef, shareUrlRef, localPathRef. Key helper: fileRefKey(ref).

Exports

| Symbol | Purpose | |---|---| | DocumentSource, FileRef, FileMeta, ReadOpts | port types | | sharePointPathRef / driveItemRef / shareUrlRef / localPathRef | ref constructors | | fileRefKey | stable string key for a ref | | IsoUtcTimestamp | branded canonical-ISO-8601-UTC timestamp type for FileMeta.lastModified | | isoUtcFromDate(d) / parseIsoUtc(value) | mint/parse an IsoUtcTimestamp (parse normalises offsets to …Z, Errs on garbage) | | createCachedDocumentParser(parse) | memoize an expensive bytes→value parse, keyed by file fingerprint (eTag, else lastModified+sizeBytes) | | unsupportedRefError(adapter, ref) | fail-closed error adapters return for foreign variants | | createFakeDocumentSource(routes), FakeDocRoute | in-memory fake for node tests |

Importing this package (directly or via an adapter) augments CapabilityRegistry so requires: ["documents"] is valid and ctx.documents is typed.

Why a separate package

Extracted from @fuguejs/ms-graph when the second adapter (@fuguejs/fs) arrived, so both share one FileRef type and one registry augmentation — per "extract on second implementation" (ADR-0052). The runtime ref↔adapter guard (each adapter fails closed on variants it doesn't implement) is load-bearing now that two adapters share the union.