@x12i/memorix-data

中文文档
3.8.0发布于 2026/11/03exellix-licenseTypeScriptES Module

Memorix data plane: scope/routing (5A), V2 writer (5B), reader (5C), abstract reverse-write (5D), relationship store/read (5E).

原始使用文档
文档目录7 节
  1. Install
  2. Write ops
  3. Read ops
  4. Abstract reverse-write
  5. Quick example
  6. Related
  7. Docs

@x12i/memorix-data

Memorix data plane: scoped routing, record directory, V2 content writer / reader, sibling compose, abstract reverse-write, and relationship reads (expansion).

All subject mutations go through this plane (or Memory / relationship engines that call it). Never write domain documents with raw Mongo drivers.

Install

npm install @x12i/[email protected]
AudienceUse this package?
Remote appNo — call memorix-service /api/data
Platform / service compositionYes

Write ops

add · upsert · patch · replace · remove

Each requires MemorixScope (orgId + agentIds[]) and a precondition (absent or exact revision). Stale revision → conflict.

Read ops

getContent · listContent · composeSubject · getAbstract · listAbstract

Counts: countLiveContent (one pair, logically deleted rows excluded), countDirectoryRecords (directory documents per object type), and countDirectoryRecordsWithoutContent (directory documents whose contentTypes is empty or only relationships).

Default reads return one logical V2 record (_id stripped). Pass relationship include options for virtual { source, relationships } expansion. Link mutation is not here — use @x12i/memorix-relationships.

Abstract reverse-write

patchAbstract → reverse mappings → one concrete writer patch. No abstract collections / abstract recordId.

Quick example

import { createMongoContentWriter, createMongoContentReader } from "@x12i/memorix-data";

const writer = createMongoContentWriter({ client, /* routing */ });
const reader = createMongoContentReader({ client, /* routing */ });

await writer.add(scope, {
  draft: { /* MemorixRecordDraft V2 */ },
  precondition: { kind: "absent" },
});

const record = await reader.getContent(scope, {
  objectType: "work-items",
  contentType: "snapshots",
  recordId: "WI-100",
});

const composed = await reader.composeSubject(scope, { recordId: "WI-100" });
// composed.contents → { raw: [...], snapshots: [...], ... }
NeedPackage / API
Envelope validate@x12i/memorix-format
Four-field links@x12i/memorix-relationships
HTTP/api/data, /api/data/compose, /api/data/abstract

Docs

npm test

版本与发布记录

@x12i/memorix-data 共发布 23 个版本,首次发布于 2026/07/22;过去 12 个月发布了 23 个版本。

版本发布日期距今
3.8.0latest2026/11/03今天
3.7.12026/11/03今天
3.7.02026/10/259 天前
3.6.02026/10/259 天前
3.5.02026/10/2311 天前
3.4.02026/10/2311 天前

其他发布通道:next → 3.0.0,rc → 3.0.7。

关于 @x12i/memorix-data 的常见问题

@x12i/memorix-data 是什么?

内存数据平面:作用域/路由(5A)、V2写(5B)、读(5C)、抽象逆写(5D)、关系存储/读(5E)。

如何安装 @x12i/memorix-data?

在项目目录运行 npm install @x12i/memorix-data,或使用 pnpm add / yarn add / bun add。

@x12i/memorix-data 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@x12i/memorix-data 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@x12i/memorix-data 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@x12i/memorix-data 可以商用吗?

@x12i/memorix-data 使用 exellix-license 许可。声明的许可为 exellix-license,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@x12i/memorix-data 还在维护吗?

最新版本 3.8.0 发布于 2026/11/03(今天);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/07/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。