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

@x12i/memorix-completion

v1.33.0

Published

Fill missing entity and event data in Memorix from source database records using JSON completion mappings

Readme

@x12i/memorix-completion

Folder name: this package lives in memorix-compeletion/ (typo). The npm package is @x12i/memorix-completion.

Fill missing fields in Memorix entity, event, and knowledge records by looking up data in source MongoDB databases, using JSON completion mappings or Catalox (--source catalox).

Mappings are plain JSON files (arrays of mapping objects). Use {{ENV.variableName}} tokens in strings; they resolve via @x12i/env-tokens at load time.

Install

npm install @x12i/memorix-completion

Quick start

Set MONGO_URI and run. Database names and entity/event routing are resolved internally (defaults: memorix-entities, memorix-events).

MONGO_URI=mongodb://localhost:27017
npx memorix-complete --mappings ./my-mappings.json

Source database for enrichment: set MEMORIX_SOURCE_DB or per-mapping source.databaseName.

See Memorix Database Conventions for shared naming rules across x12i peers.

Databases (advanced overrides)

Each mapping declares a target — either entity or event — which determines which Memorix database receives updates:

| Target | Env variable | Default database | |--------|--------------|------------------| | entity | MEMORIX_ENTITIES_DB | memorix-entities | | event | MEMORIX_EVENTS_DB | memorix-events |

Source records are read from a separate database configured per mapping (or via env defaults):

| Env variable | Purpose | |--------------|---------| | MEMORIX_SOURCE_DB / SOURCE_DATABASE_NAME | Default source database when not set in mapping | | mapping.source.databaseName | Per-mapping source DB (supports {{ENV.*}}) |

Mapping JSON

Each mapping file is a JSON array. Example entry:

{
  "name": "complete-vulnerability-entity-missing-data",
  "entityType": "vulnerability",
  "target": "entity",
  "version": "1.0.0",
  "enabled": true,
  "targetCollection": "vulnerabilities",
  "targetSelector": {
    "sourceCollection": "vulnerabilities-information"
  },
  "source": {
    "databaseName": "{{ENV.sourceDatabaseName}}",
    "collection": "vulnerabilities-information"
  },
  "match": {
    "targetPath": "entityId",
    "sourcePath": "vulnerabilityId"
  },
  "writeRoot": "data",
  "mode": {
    "onlyFillMissing": true,
    "overwriteExisting": false,
    "createNestedObjects": true
  },
  "ignore": {
    "exactProperties": ["_id", "metadata"],
    "idProperties": true
  },
  "fields": [
    { "sourcePath": "enrichment", "targetPath": "enrichment" }
  ]
}

| Field | Description | |-------|-------------| | target | entity or event — selects Memorix database and record type | | targetCollection | Memorix Mongo collection for target records (recommended) | | targetCollectionCandidates | Extra names to try if targetCollection is omitted | | targetSelector.sourceCollection | Source lineage selector; matches _system.provenance.source.collection | | source.databaseName / collection | Source DB lookup (supports {{ENV.*}}) | | match.targetPath / sourcePath | Join key between Memorix record and source document | | fields | Paths to copy from source → target data |

For event mappings, set "target": "event" and point targetCollection at the appropriate collection in memorix-events.

CLI

After npm run build:

# Dry-run (default)
npx memorix-complete --mappings ./my-mappings.json

# Write to Mongo
npx memorix-complete --mappings ./my-mappings.json --write

# Filters
npx memorix-complete -m ./my-mappings.json --entity vulnerability --target entity --limit 100 --write

Environment:

  • MONGO_URI — required Mongo connection (simple mode)
  • MEMORIX_SOURCE_DB / SOURCE_DATABASE_NAME — source database when not in mapping
  • MEMORIX_ENTITIES_DB / MEMORIX_EVENTS_DB — optional overrides (defaults shown below)
  • MEMORIX_ENTITIES_COLLECTION_<ENTITY_TYPE> — optional entity collection override
  • MEMORIX_EVENTS_COLLECTION_<ENTITY_TYPE> — optional event collection override
  • MEMORIX_COMPLETION_MAPPINGS — default mappings file path for CLI
  • MEMORIX_COMPLETION_TARGET — default target filter (entity, event, or all)

Programmatic API

Full Mongo pipeline (mappings file → read → complete → write)

import {
  runMongoCompletion,
  summarizeCompletionResults,
  loadCompletionMappingsFromFile
} from "@x12i/memorix-completion";

const report = await runMongoCompletion({
  mappings: "./completion-mappings.json", // or pre-loaded array
  dryRun: true,
  limit: 0, // 0 = all records per mapping
  filter: { entityType: "vulnerability", target: "entity" }
});

console.log(summarizeCompletionResults(report.results));

Host-provided I/O (any database)

import {
  runMemorixCompletion,
  loadCompletionMappingsFromFile
} from "@x12i/memorix-completion";

const mappings = loadCompletionMappingsFromFile("./completion-mappings.json");

const results = await runMemorixCompletion({
  sourceDatabaseName: mappings[0].source.databaseName,
  records,
  mappings,
  dryRun: false,
  sourceReader: async ({ databaseName, collection, matchPath, matchValue }) => {
    return findOne({ db: databaseName, collection, filter: { [matchPath]: matchValue } });
  },
  recordWriter: async ({ record, updatedData }) => {
    await updateRecord(record.recordId, { data: updatedData });
  }
});

Load mappings only

import { loadCompletionMappingsFromFile } from "@x12i/memorix-completion";

const mappings = loadCompletionMappingsFromFile("./maps.json", {
  env: process.env // default; resolves {{ENV.*}}
});

Mongo adapters (custom orchestration)

import {
  connectMongoCompletion,
  createMongoSourceReader,
  createMongoRecordWriter,
  loadRecordsFromCollection,
  resolveTargetCollectionName,
  resolveMemorixDbName
} from "@x12i/memorix-completion";

const entitiesDb = resolveMemorixDbName("entity");
const eventsDb = resolveMemorixDbName("event");

Core exports

| Export | Description | |--------|-------------| | runMongoCompletion | End-to-end runner from mapping JSON file(s) | | runMemorixCompletion | Batch runner with injected readers/writers | | completeMemorixRecord | Single-record completion | | loadCompletionMappingsFromFile | Load + resolve {{ENV.*}} in mapping JSON | | resolveJsonEnvTokens | Deep token resolution on any JSON value | | filterCompletionMappings | Filter by entity, target, name, enabled, fields | | resolveMemorixDbName | Resolve entity/event Memorix database from env | | resolveDefaultSourceDbName | Resolve default source database from env |

Scripts (this repo)

npm run build
npm test
npm run poc:live -- --dry-run --entity vulnerability --target entity --limit 10
npm run complete -- --mappings test/poc-data-fix.json --write

Publish

From the x12i workspace root:

./scripts/publish-memorix-packages.sh