ExtantApe

payload

by ExtantApe
OnePedigree
Other
v3
~3.92.1 || ~3.93.0 || ~3.94.2
NOASSERTION

Overview

Summary generated from the README

Adds parentage tracking to a Payload collection, in three modes: managed collections, standard fields added to yours, or mapping to your own fields. Writes are checked for self-parents, duplicates and cycles, and reads respect access control by hiding private relatives. It exposes pedigree, relatives and validate endpoints and adds an Admin pedigree panel. Requires Payload 3.92 to 3.94 and React 19 or later, and is licensed for noncommercial use.

Features

  • Parentage group with parent rows, roles, kinds such as adoptive or donor, and reproductive mode
  • Cycle, self-parent and duplicate-parent rejection with serialized concurrent edits
  • Cohorts as birthing events with optional confirmWrite hook for extra checks
  • Pedigree endpoints covering 13 views, plus relatives, validate and cohort members
  • Private relatives shown as placeholders or omitted according to the requester's read access
  • Admin pedigree preview panel and a settings global for color themes

Use cases

  • Build animal breeding records with studbook pedigrees and litter or clutch tracking
  • Model family trees on an existing collection while keeping private relatives hidden from unauthorized users
  • Prevent circular or inconsistent ancestry when many editors change parentage at the same time

From the author

OnePedigree for Payload: parentage fields, cycle-safe parentage writes, deletion policies, permission-aware pedigree endpoints for all 13 views, and Admin previews.

Installation

npm i @extantape/payload-plugin-onepedigree

0

Stars

0

Forks

4

Open Issues

Yesterday

Last Updated

915

Weekly Downloads

v0.1.0-alpha.27

npm Version

227.3 KB

Unpacked Size

2

Dependencies

Repository stars

00 since Oct 25

Show data
Repository stars by day (UTC)
DateStars
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20260

Shared by 2 plugins in ExtantApe/OnePedigree.

npm weekly downloads

961+961 since Nov 2

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 2026961
Dec 4, 20261,284
Dec 3, 20261,303
Dec 2, 20261,289
Dec 1, 2026827
Nov 30, 2026691
Nov 29, 2026758
Nov 28, 2026698
Nov 27, 2026325
Nov 26, 2026271
Nov 25, 2026232
Nov 24, 2026189
Nov 23, 2026319
Nov 22, 2026212
Nov 21, 2026208
Nov 20, 2026205
Nov 19, 2026200
Nov 18, 2026194
Nov 17, 2026180
Nov 16, 20260
Nov 15, 2026926
Nov 14, 20261,063
Nov 13, 20261,064
Nov 12, 20261,470
Nov 11, 2026993
Nov 10, 20261,132
Nov 9, 20261,693
Nov 8, 20261,614
Nov 7, 20261,431
Nov 6, 20261,389
Nov 5, 2026865
Nov 4, 2026796
Nov 3, 20260
Nov 2, 20260

Each point is npm's rolling 7-day download count.

Health Score

66/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1440463679-payload.svg)](https://payloaddirectory.dev/plugins/1440463679-payload)
HTML
<a href="https://payloaddirectory.dev/plugins/1440463679-payload"><img src="https://payloaddirectory.dev/badge/1440463679-payload.svg" alt="Payload Directory"></a>
Updated Dec 4, 2026Created Oct 31, 2026Published Nov 29, 2026

README

@extantape/payload-plugin-onepedigree

OnePedigree for Payload CMS 3: parentage on your own collection, cycle-safe writes, deletion policies, permission-aware pedigree endpoints for all 13 views, and Admin components (pedigree preview, relatives, color theme settings).

import { onePedigree } from '@extantape/payload-plugin-onepedigree'

export default buildConfig({
  collections: [Animals, Clutches],
  plugins: [
    onePedigree({
      collection: 'animals',
      mode: 'standard-fields', // or 'managed' (creates the collections) or 'mapped' (your fields)
      cohorts: { collection: 'clutches' },
      hiddenRecords: 'placeholder', // a private relative shows as an anonymous "private record"
      navigation: { individualUrl: '/animals/{id}' },
    }),
  ],
})

Identifiers beside names

fields.identifier shows a host identifier after each name in every view, relatives list and spoken name, e.g. "Mead (REG-AQCR6T)". Give a field path, or a function of the requester so each person can choose, for example a registry ID or their own studbook number:

fields: { identifier: ({ user }) => (user?.showStudbook ? 'studbookNo' : 'coId') }

A record the requester can't read never shows its identifier: its placeholder carries none. React's Terminology.identifierFormat (default {label} ({id})) changes how the two are joined.

Modes

  • managed: creates individuals-style and cohort collections from the factories (createIndividualsCollection, createCohortsCollection).
  • standard-fields (default): adds the parentage group (parents[{ individual, role, kind }], reproductiveMode, cohort) to your existing collection.
  • mapped: uses your fields, e.g. { kind: 'role-fields', roles: { mother: 'dam', father: 'sire' }, cohort: 'clutch' } or { kind: 'parent-array', path: 'lineage', individualField: 'animal', roleField: 'role' }. A row's kind is read from kindField (default kind); without one, every link is biological.

Each parents row has an optional kind: empty means biological, or donor (a gamete donor, also genetic), surrogate, legal, adoptive or social (add your own with kinds). Only biological links count for siblings, relatedness and genetics; the others, such as a foster dam, are shown dotted and labelled. The Mother/Father pickers edit only the biological rows.

The plugin never creates collections for parents, roles, modes, graph edges or occurrences.

Parent labels

Stored roles stay mother / father; only the words change. terminology.parents sets the default ('mother-father' (default), 'dam-sire', 'female-male-parent', or custom { maternal, paternal }). Add createParentTermsPreferenceField() to your users collection and pass its path as terminology.userPreference: each user then sees their own choice in the Mother/Father pickers and in relatives.

Cohorts are birthing events

A cohort is one birthing event (a clutch, a litter, twins): one mother, fathers may differ per member. With cohorts.birthParentField (the cohort's field naming the mother), a member whose recorded mother differs is refused, and so is changing the cohort's mother while members disagree.

These checks compare only records the requester can read. Server code with access overridden is checked against all records. A save by an editor with limited read access can therefore leave a member's mother and the cohort's birthing parent different; if your data must always agree, check it in trusted server code, or with cohorts.confirmWrite (below). A birthing parent the requester can't read comes back from cohort reads as { "private": true } (null in GraphQL; with hiddenRecords: 'omit' it is left out of the record) and is kept as stored when they save the cohort. They can't change or remove it, and a cohort can't be saved with a new birthing parent the editor can't read.

cohorts.confirmWrite is an optional hook for that last check, on writes the plugin could only check against what the requester can read. With birthParentField set and access control on, the plugin calls it after its own checks pass, for:

  • every create of an individual, in a cohort or not
  • every update of an individual that changes its parents, reproductive mode or cohort, in any locale, joining or leaving a cohort included
  • every create of a cohort with a birthing parent, and every update that sets, changes or clears a cohort's birthing parent, in any locale
  • every call to the validate endpoint

Drafts, bulk updates, duplicates and version restores are included. When it is asked never depends on a stored value the requester can't read, and neither do its arguments: id and cohort name only records the requester can read, and are null otherwise. Its answer must not depend on what they can read either.

For an individual, the hook is asked once for each cohort the requester can read that the record will be in, in any locale. A locale: 'all' write can put a record in a different cohort per locale, and a duplicate copies the cohorts of every locale, so one write can mean several calls, each with one cohort. Every call must answer true. cohort is null only when the record will be in no cohort the requester can read, and in that case the hook is asked once. A write naming more than 32 readable cohorts, a value nested too deep to read, or a value the database can't look up as a cohort ID, is refused without asking. A cohort that doesn't exist is left out the same way as one the requester can't read. Treat cohort: null as "no cohort this requester can see", never as permission to join any cohort. Only a return value of exactly true lets the write go ahead. Anything else, a throw, a rejected promise or no answer within cohorts.confirmWriteTimeout milliseconds (default 10000) refuses it with one message, This change to a birthing event (cohort) was not confirmed, so it can’t be saved., and the error itself isn't shown. The time limit only stops the write waiting; the plugin can't stop the hook itself. A hook that answers after the time limit and then writes on req still commits that write, even though the request it was asked about was refused. It gets the write's own req (same user and transaction), so it can read with overrideAccess: true on that req. It should only read. In a bulk update, anything it writes on that req stays written even when the document it was asked about is refused, so don't rely on rollback.

cohorts: {
  collection: 'clutches',
  birthParentField: 'mother',
  confirmWriteTimeout: 5000,
  // kind: 'member' | 'birthParent'; operation: 'create' | 'update' | 'validate'
  // id: the individual or the cohort; cohort: the cohort. Null when new, none, or not readable.
  confirmWrite: async ({ req, kind, operation, id, cohort }) => myBirthingRules(req, { kind, operation, id, cohort }),
},

Trusted operations (overrideAccess: true) never call it, and without it nothing changes. It isn't called for deletes, for an update that changes none of the fields above (a rename, say), for a cohort created without a birthing parent, or when the plugin's own checks already refused the write.

A member's cohort follows the same rules with access control on. A new or different cohort must be one the editor can read; one they can't read gets the same message as one that doesn't exist (UNRESOLVED_COHORT). The cohort already stored on the record is kept on save. A cohort the requester can't read comes back from individual reads, version reads included, as { "private": true } (null in GraphQL; with hiddenRecords: 'omit' it is left out of the record). Relatives and pedigree responses show no cohort for that member, and the cohort view treats a cohortId they can't read as no cohort. When that editor saves the member, the stored cohort is kept; they can't change or remove it. If the cohorts collection's read access throws, the cohort counts as unreadable. Imports that run with access control on can only link cohorts the importer can read. Server code that needs the stored ID should read with trusted access or withStoredParents.

With hiddenRecords: 'omit', a cohort the editor can't read is left out of the record, like no cohort at all, but it is still stored and kept. Setting a different cohort on that member, or restoring a version that would change it, is refused for that editor. Give them read access to the cohort, make the change in trusted server code, or use hiddenRecords: 'placeholder' so they can see a cohort is set.

Writing parent and cohort references

With access control on, every parent field, parent row, picker, cohort and cohort birthing parent in a create or update takes one of these: an ID, a populated document with an id, null, or the { "private": true } placeholder. Any other shape (an array, { id: [...] }, an object without an id, a value nested more than 16 levels deep) is refused with the same message as a record that doesn't exist. Each new reference must name a record the editor can read. This covers every way in: create, update, bulk update, duplicate, drafts, autosave, REST, GraphQL and the Admin, and with locale: 'all' each locale's value is checked on its own. A reference already stored on the record is kept at its own field and locale. An editor who can't read it can't move it to another field, picker or locale; that gets the same answer as a record that doesn't exist. Parent rows can still be reordered or removed.

To keep a stored reference the editor can't read, leave it out of the write or send the placeholder or an empty value. A parent row that names no parent but keeps its stored row id also keeps that row as stored. Sending the stored ID itself back is refused. A parent row naming it is refused. The validate endpoint answers the same way for the cohort already stored on the record.

Your own beforeValidate hooks on these collections run before the plugin's. When an editor who can't read a stored reference leaves it out of a write, the plugin still checks the write after your hooks have run: if a hook cleared or removed that reference it is put back as stored, if a hook replaced it the write is refused, and a parent row a hook changed or removed is kept as stored alongside whatever the hook wrote. Parent rows the editor left out stay as stored in the locale being written, including when a hook removes the parentage group, sets it to null or removes its rows. To change such a reference from a hook, make that change in trusted server code instead.

Have your hooks edit parent rows and parent fields only when they need to. A hook that rewrites them on every write will have some saves refused, for records that store a parent the editor can't read.

A version restore (restoreVersion or the Admin) is checked in every locale against what its user can read, with access control on or off. A value that user can't read comes back only where it is still stored, at the same field and locale; otherwise the restore is refused with the same answer as a record that doesn't exist. A restoreVersion call with overrideAccess: true and no user can read nothing, so it is checked the same way and can bring back only references still stored. Give each restore its own req. If two restores of the same record run at once on one shared req, both may be refused, or one may be refused because its version couldn't be checked while the other goes through after the full check. A restore whose version couldn't be checked is always refused. After a restore fails, a later restore of that record on the same req may be refused too, so try again with a fresh request. To restore such a version anyway, do it in trusted code: read the version with locale: 'all' and write its values back:

const { parent, version } = await payload.findVersionByID({ collection: 'animals', id: versionId, locale: 'all', depth: 0 })
await payload.update({
  collection: 'animals',
  id: parent,
  data: { dam: version.dam, sire: version.sire, clutch: version.clutch },
  locale: 'all',
  overrideAccess: true,
})

Duplicating a record with access control on copies only the parents, parent rows, cohort and birthing parent the requester can read. Trusted duplicates copy everything.

The plugin's request markers live under private keys. Values a caller puts in context under the plugin's names (onepedigreeOverrideAccess, onepedigreeRawParents and the cache names) are ignored; trusted code passes overrideAccess: true or uses withStoredParents. onepedigreeInternal skips the parentage checks only on a trusted operation (overrideAccess: true). With access control on it switches nothing off.

Queries on parent and cohort fields

These rules apply whenever access control is on (REST, GraphQL, the Admin, and the Local API with overrideAccess: false). Trusted Local API calls are unaffected. They cover every collection in the host, including paths that reach a parent field through relationships (animal.dam, animal.clutch.mother) and joins, on find, count, versions, distinct values, and bulk update and delete. A refused query gets a 400.

  • Parent fields (including the cohort's birthing parent) and the individuals' cohort field can't be sorted by, listed as distinct values or filtered below (dam.name, clutch.name, clutch.mother). This holds for every requester with access control on, including one who can read that parent. To find individuals by birthing parent, query the cohorts first (where[mother][in]=<ids>), then the individuals by those cohort IDs (where[clutch][in]=<ids>).
  • equals, in, not_equals and not_in work when the requester can read every ID given (every parent, or every cohort). Other operators are refused, in counts and version queries too.
  • exists and empty values work only with hiddenRecords: 'placeholder'.
  • In a standard-fields install the same rules cover the parents rows array and every field in a row, including role and id.
  • On any collection, these are also refused: a filter or sort key that Payload can't resolve, a key longer than 100 segments, a path through more than eight relationships, a where nested deeper than 32 levels, an unknown join name, and an object under a relationship other than Payload's nested contains or a plain { relationTo, value } reference.

Only relationship paths are covered. If you also store a parent ID in a text or JSON field, restrict it in your own access rules.

A global that refers to individuals or cohorts (directly, or through relationship, upload or join fields) allows version reads only to requesters who can read every individual. This includes the version history in the Admin. If others need it, read the versions in your own server code and return what they may see. Other globals keep your readVersions rule.

Setup requirements

  • Use Payload 3.92.1 or later on the 3.92 line, 3.93.0 or later on the 3.93 line, or 3.94.2 or later on the 3.94 line (~3.92.1 || ~3.93.0 || ~3.94.2), and the same range of @payloadcms/ui if you use it. The range widens one minor version at a time, after the tests pass on it. On 3.94.2, Payload itself needs Next.js 16.4.5 or later on the 16 line.
  • Leave allowAdditionalKeys unset (or false) in mongooseAdapter(). With it on, Payload refuses to start or to answer queries.
  • Add the individuals and cohorts collections before this plugin. In managed mode, let the plugin create the cohorts collection with cohorts.managed.
  • Plugins that run after this one must keep those two collections, their hooks, their read access (field read access included), the database adapter and the key-value store. Collections and globals they add are covered, and their hook lists must stay changeable. Keep the plugin's beforeOperation and afterOperation hooks on those two collections in their order. Without them, writes and restores are refused where they should go through.
  • Keep afterRead hooks you add to those two collections on the requester's access. Don't read the record again with overrideAccess: true and return that result.

The plugin wraps the database adapter, the key-value store (kv; Payload's default one if you set none) and your email adapter if you have one, so it can check the running config. No database change is needed. If the check fails, Payload refuses to start or refuses queries; the error or your plugin order shows what to fix. If a later plugin replaces the adapter and you start with onInit off, the first query or Admin permissions request may be refused once; retry it.

Integrity

On every write (Admin, REST, GraphQL, Local API, imports):

  • self-parents, duplicated parents and cycles are rejected with field-addressable errors; the cycle check walks the full stored descendant line, and every loop is refused with the same message (match on the code, PARENT_IS_DESCENDANT);
  • a new parent the editor cannot read is rejected, with the same message as a missing one, and so is a new or changed cohort, and so is a reference in any shape other than an ID, a document or the placeholder (see Writing parent and cohort references);
  • host rules (e.g. taxonomy) run on the proposed record;
  • parentage changes are serialized: each updates an internal graph-revision global in the same transaction, so two concurrent edits that would together form a cycle cannot both commit (requires a MongoDB replica set or another adapter with transactions).

The pedigree endpoint's revision is a fingerprint of what that requester received. It changes when their view changes and only then, so use it as a cache key and compare it for equality only.

Deleting a recorded parent is refused (onReferencedIndividualDelete: 'restrict', default) or removes the references ('detach').

Endpoints

Route
GET /api/<collection>/:id/pedigree?view=…Projection + layout; ancestorDepth, descendantDepth, relatedId, cohortId, occurrenceMode, includeSiblings, orientation, maxNodes, layout=false
GET /api/<collection>/:id/relativesParents, offspring, siblings (full / partial / unresolved), cohort mates
POST /api/<collection>/:id/pedigree/validateCheck { parents, reproductiveMode, cohort } without saving (needs update access)
GET /api/<cohorts>/:id/membersMembers the requester may see

Every read runs as the requester (access control applies), is bounded by limits (maxDepth, maxNodes) and returns display projections, not documents. A parent the requester cannot read is left out or shown as an anonymous placeholder.

The same holds for plain collection reads (REST, GraphQL, the Admin, and the Local API with overrideAccess: false), single or list, at any depth. A parent the reader can't read comes back as { "private": true } with hiddenRecords: 'placeholder', or is left out of the record (the key is absent) with 'omit'. In a locale: 'all' read of a localized field with 'omit', a hidden locale is left out of the locale map, and a value hidden in every locale leaves no key. GraphQL returns null for it. Trusted Local API reads (the default overrideAccess: true) are unchanged. When someone saves a record that showed them a private parent, that parent is kept as stored: a placeholder, an empty picker or a missing row means "unchanged", and replacing it with another parent is refused. An update that carries the parentage group as something other than an object (an array, a string, a number) is refused with a 400 for every record. The kept parent also passes the parent field's validation, which would otherwise look it up with the editor's access whenever the field has filterOptions (as the multi-tenant plugin adds); other values are validated as usual.

Add an index on the parent path (parentage.parents.individual, or your role fields) in production; the standard fields declare it.

Admin

  • A pedigree panel on the edit view: preview of the saved record in any view (pan, zoom, selection), relatives, and structural notices.
  • A Pedigree settings global: color theme (seven presets, per-view accents, hex editing) used by the preview; read it in your frontend to match.

On its own, and with others

On its own: the plugin needs only Payload. It doesn't need OnePhylogeny, OneTaxonomy or any EXTANT APE Payload plugin.

Needs: Payload ~3.92.1 || ~3.93.0 || ~3.94.2 and React >=19 as peer dependencies, with @payloadcms/ui optional on the same Payload range. That covers Payload 3.92 and 3.93, and 3.94.2 or a later 3.94 release. A site on 3.95 or later can't install this version. No other EXTANT APE plugin is required.

Works with: no other plugin is wired to it yet.

Color Theory: no link yet. The Pedigree settings global keeps its own color presets for the pedigree view, set apart from Color Theory.

License

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

Similar plugins