@captiveorigins/onepedigree-core

中文文档
0.1.0-alpha.15发布于 2026/11/09PolyForm-Noncommercial-1.0.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 1903

OnePedigree core: the species-neutral pedigree data model, validation, bounded traversal, view projections and layout, with no React, Payload or database dependency.

原始使用文档
文档目录6 节
  1. Principles
  2. Quick start
  3. Views
  4. Genetics
  5. Development
  6. License

OnePedigree

A species-neutral pedigree framework for humans and other animals (and plants): a portable data model, graph validation, bounded ancestry traversal, view projections, automatic layout, server-renderable React components and a Payload CMS plugin.

Status: alpha. The schema-version-1 contract is stable in intent; package APIs may still change before the first prerelease.

PackagePurpose
@captiveorigins/onepedigree-coreData model, normalization, validation, traversal, projections, layout, serialization. No React, Payload or database dependency.
@captiveorigins/onepedigree-reactServer-renderable SVG views (all 13), interactive explorer, headless hooks, CSS-variable styling.
@captiveorigins/payload-plugin-onepedigreePayload plugin: managed, standard or mapped collections, cycle-safe serialized writes, deletion policies, permission-aware endpoints, Admin preview and color settings.

Principles

  • Parentage lives on the individual: parentage.parents[{ individual, role }], reproductiveMode (sexual, parthenogenesis, self, asexual, cloning, other) and cohort. Children and siblings are derived, never stored.
  • Unknown stays unknown. Roles are never inferred from sex; a missing parent or mode is not guessed; incomplete pedigrees are valid (they produce notices, not errors).
  • Bounded and cycle-safe. Every traversal has depth and size limits and reports truncation; cycles are rejected.
  • Identity vs occurrence. One stored individual may appear several times in a view; occurrences always map back to the one identity.

Quick start

import { getAncestors, indexPedigree, validatePedigree, type PedigreeDocument } from '@captiveorigins/onepedigree-core'

const pedigree: PedigreeDocument = {
  schemaVersion: 1,
  individuals: [
    { id: 'atlas', label: 'Atlas', sex: 'male' },
    { id: 'nova', label: 'Nova', sex: 'female' },
    {
      id: 'ember',
      label: 'Ember',
      parentage: {
        parents: [
          { individual: 'nova', role: 'mother' },
          { individual: 'atlas', role: 'father' },
        ],
        reproductiveMode: 'sexual',
      },
    },
  ],
}

const { valid, issues } = validatePedigree(pedigree)
const ancestors = getAncestors(indexPedigree(pedigree), 'ember', { maxGenerations: 4 })

Large datasets: implement PedigreeRepository (getByIds, findChildrenOf) and call loadNeighborhood(); it loads a bounded neighborhood one query per generation.

Views

pedigree, fan, ahnentafel, descendants, hourglass, cohort, relationship, timeline, inbreeding, population, compact, maternal, paternal: each with a projection (projectPedigree), a built-in deterministic layout (layoutPedigree; tree, layered or radial, vertical or horizontal) and a React renderer. Custom layout engines (e.g. ELK) plug in through PedigreeLayoutEngine.

For a list instead of a chart ("show all relatives"), relativesByGeneration(projection) groups an hourglass projection's relatives by generation (parents, grandparents, …, siblings, offspring, …); generationKind() gives hosts the kind and number of "great"s to translate, and generationLabel() an English label.

Genetics

Optional and separate from the pedigree document (schema 1 is unchanged): the host supplies a gene catalog (GeneDefinition: recessive, incomplete dominant, dominant, codominant, polygenic or unknown; allelic complexes via a shared locus; Z- or X-linked) and per-individual GenotypeRecords (visual, single, super, het, possible het with a chance, non-carrier, unknown; with how it is known).

  • pairingOdds — expected offspring per locus (super forms, complexes, sex-linked splits by offspring sex); unrecorded genes are assumed absent and reported as assumptions.
  • expectedNormalLookingRecord — e.g. 66% possible het from two hets.
  • checkOffspring — flags offspring the recorded parents can't produce (check parentage).
  • carrierFromOffspring — carriers proven by a visual recessive offspring; suggestions only (basis: 'inferred').
  • genotypeSummary — "Super Pastel 66% possible het Pied" from the records.

Nothing is guessed: polygenic and unproven genes have no odds, and a sex-linked gene needs the sex. In @captiveorigins/onepedigree-react, genotypes draws allele dots for several genes on every node (two dots per gene, one per copy), GenotypeDots draws them anywhere, and geneOverlay focuses on one gene with the usual genetic pedigree symbols and GeneLegend.

Development

pnpm install
pnpm typecheck && pnpm test && pnpm build   # build also writes apps/playground/dist (gallery.html, index.html)

apps/playground shows every view for every fixture: dist/gallery.html (static, server- rendered) and dist/index.html (interactive; serve the folder, e.g. python3 -m http.server).

License

PolyForm Noncommercial 1.0.0. Free for noncommercial use, with attribution; commercial use needs a separate license from Captive Origins. Versions published before this change remain under MIT.

版本与发布记录

@captiveorigins/onepedigree-core 共发布 11 个版本,首次发布于 2026/11/01;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.0-alpha.132026/11/09今天
0.1.0-alpha.15latest2026/11/09今天
0.1.0-alpha.122026/11/063 天前
0.1.0-alpha.112026/11/036 天前
0.1.0-alpha.102026/11/036 天前
0.1.0-alpha.92026/11/036 天前

其他发布通道:alpha → 0.1.0-alpha.8。

关于 @captiveorigins/onepedigree-core 的常见问题

@captiveorigins/onepedigree-core 是什么?

OnePedigree core: the species-neutral pedigree data model, validation, bounded traversal, view projections and layout, with no React, Payload or database dependency.

如何安装 @captiveorigins/onepedigree-core?

在项目目录运行 npm install @captiveorigins/onepedigree-core,或使用 pnpm add / yarn add / bun add。

@captiveorigins/onepedigree-core 支持 TypeScript 吗?

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

@captiveorigins/onepedigree-core 支持 ESM 还是 CommonJS?

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

@captiveorigins/onepedigree-core 需要什么版本的 Node.js?

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

@captiveorigins/onepedigree-core 可以商用吗?

@captiveorigins/onepedigree-core 使用 PolyForm-Noncommercial-1.0.0 许可。声明的许可为 PolyForm-Noncommercial-1.0.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@captiveorigins/onepedigree-core 的下载量有多少?

根据 npm 官方下载统计,@captiveorigins/onepedigree-core 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,903 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@captiveorigins/onepedigree-core 还在维护吗?

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