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

xmemory-records-mapper

v1.0.0

Published

Discovers and persists **mapping relationships** between MongoDB collections into [XMemory](https://github.com/nx-intelligence) at three levels:

Readme

@xmemory/records-mapper

Discovers and persists mapping relationships between MongoDB collections into XMemory at three levels:

  1. Collection level — collection ↔ collection
  2. Schema/field level — field ↔ field
  3. Record level — document ↔ document

It writes these mappings as Things and edges into XMemory:

  • Things via @xmemory/equal (xmemory-equal)
  • Edges via @xmemory/relations (xmemory-relations)

It can use:

  • nx-semantic-matcher (deterministic semantic matching) — optional
  • nx-ai-api (LLM-assisted collection/field mapping) — optional but recommended

This package does not scope, traverse, or answer questions — that is the responsibility of @xmemory/scoper. The mapper only produces mapping data; the scoper consumes it.

Installation

npm install @xmemory/records-mapper nx-mongo xmemory-equal xmemory-relations

Optional: nx-ai-api, nx-semantic-matcher (if available).

Usage

import { createRecordsMapper, createNxMongoAdapter, createRelationsBulkAdapter, wrapEqualForMapper } from "@xmemory/records-mapper";
import { SimpleMongoHelper } from "nx-mongo";
import { createEqualClient } from "xmemory-equal";
import { createRelationsClient } from "xmemory-relations";

const nxMongo = new SimpleMongoHelper(process.env.MONGO_URI);
await nxMongo.initialize({ databaseName: process.env.MONGO_DB });

const xEqual = wrapEqualForMapper(createEqualClient({ nxMongo, namespace: "myapp" }), "myapp");
const relationsClient = createRelationsClient({ nxMongo, nxEqual, namespace: "myapp" });
const xRelations = createRelationsBulkAdapter(relationsClient, xEqual, "myapp");
const nxMongoAdapter = createNxMongoAdapter(nxMongo);

const mapper = createRecordsMapper({
  nxMongo: nxMongoAdapter,
  xEqual,
  xRelations,
  config: {
    namespace: "myapp",
    collections: [
      { server: "default", database: "db1", collection: "users" },
      { server: "default", database: "db2", collection: "accounts" },
    ],
    modes: { collections: true, schema: true, records: true },
    thresholds: {
      schemaConfidence: 0.75,
      recordConfidence: 0.75,
      equalityThreshold: 0.95,
      highTier: 0.9,
    },
  },
});

const result = await mapper.run();
console.log(result.stats);

What it does

  • Profile — Ensures collection and field Things exist in XMemory (with metadata.db, metadata.collection).
  • Collection mapping (optional) — When LLM is enabled, proposes collection pairs and writes collection-relation edges.
  • Schema mapping — Builds field ↔ field candidates (LLM-seeded or lexical/semantic), scores them, and writes schema-relation edges.
  • Record mapping — Uses schema-relation edges as drivers, batch-reads documents, matches values (semantic or equality), ensures document Things, writes record-relation edges, and promotes high-confidence matches to equality via xEqual.link.

Outputs in XMemory

  • Things: schema:collection, schema:field, record:document (each with metadata.db, metadata.collection).
  • Edges: collection-relation, schema-relation, record-relation (with confidence, tier, source, sessionId; record edges include drivingFieldRelationEdgeId).

Known limitation

Single (db, collection) per Thing. Scope metadata stores one metadata.db and one metadata.collection per node. Multi-database or cross-cluster scope is not represented by these keys.

Safety

Record payload storage is capped and configurable:

  • records.storeRecordPayload: "none" | "keys-only" | "matched-fields"
  • records.matchedFieldsMaxLen: max length for stored matched values (default 256)

API

  • run() — Full pipeline: profile → collections (if enabled) → schema → records.
  • runCollections() — Profile + collection-level mapping only.
  • runSchema() — Profile + schema (field) mapping only.
  • runRecords() — Record mapping only (assumes schema edges exist).
  • runOnDemand(pair) — Run full pipeline for a single collection pair.
  • runIncremental({ changedDocs }) — Record mapping in incremental mode (v1: delegates to full record run).

License

ISC