@extantape/payload-plugin-onephylogeny 0.0.0-stage → 0.1.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,75 @@
1
+ Required Notice: Copyright 2026 EXTANT APE (https://github.com/ExtantApe)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md CHANGED
@@ -1,3 +1,37 @@
1
- # Temporary Holding Version
1
+ # @extantape/payload-plugin-onephylogeny
2
+
3
+ OnePhylogeny for Payload: immutable reference panels and released results on your own collections, with server-enforced review, safe endpoints and no coordinates.
4
+
5
+ See the [repository](https://github.com/ExtantApe/OnePhylogeny) for documentation.
6
+
7
+ ## Samples and sequences
8
+
9
+ Pass `records` to add `samples` and `sequences`. A lab's file becomes one of each through one call:
10
+
11
+ ```ts
12
+ import { registerSequence } from '@extantape/payload-plugin-onephylogeny'
13
+
14
+ const { sample, sequence, created } = await registerSequence(payload, {
15
+ tenant, animal, kit, lab, file, // your own record IDs; taxon is read from the animal if you leave it out
16
+ sha256, // computed by your server from the stored bytes
17
+ text, // the file's contents, which must hash to sha256
18
+ marker: 'cytb',
19
+ })
20
+ ```
21
+
22
+ It refuses, in plain words, a file whose text doesn't match its SHA-256, a file with more or fewer than one sequence, characters that aren't DNA bases, a sequence outside the lengths set for its marker, and an animal with no species. Sending the same file for the same kit again changes nothing (`created: false`). It writes with full access, so check first that the caller may submit results for that kit.
23
+
24
+ A Sanger chromatogram goes in the same way, with its bytes instead of text:
25
+
26
+ ```ts
27
+ import { registerTrace } from '@extantape/payload-plugin-onephylogeny'
28
+
29
+ const { sequence } = await registerTrace(payload, { tenant, animal, kit, lab, file, sha256, bytes, fileName: 'K0001-F.ab1', marker: 'cytb' })
30
+ ```
31
+
32
+ The read is trimmed by quality and bases below Q20 become N (OnePhylogeny's `assessRead`, with its stated defaults). The kept bases are stored and tested like any sequence. The sequence's `trace` field records how the read was judged: status, kept range, raw length, mean quality, masked bases and mixed-peak count. Nothing else from the file is stored. A file that isn't a chromatogram, doesn't match its SHA-256, or holds a failed or too-short read (under 100 good bases) is refused, and nothing is stored. Joining a forward and a reverse read isn't offered here yet; send the better read.
33
+
34
+ `assignWaiting(payload, { evaluate })` is the sweep. It tests each waiting sequence against the panel for its marker and species, using the `evaluate` function you pass (OnePhylogeny's `testSample` in a Node job), and records a result pending review. A sequence with no panel stays waiting, and one the panel's checks refuse is marked `not-assessable`, with the reason. Results reach readers only after a reviewer approves them.
35
+
36
+ On a multi-site host, set `tenantField` if the site field isn't called `tenant`. A result, sample or sequence keeps the site it was made for, so nobody can move it to another site's readers.
2
37
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
@@ -0,0 +1,192 @@
1
+ import { Result } from '@extantape/onephylogeny-core';
2
+ import { Access, PayloadRequest, Payload, Where, Plugin } from 'payload';
3
+
4
+ /** Settings for the optional `samples` and `sequences` collections. */
5
+ type RecordsOptions = {
6
+ slugs?: {
7
+ samples?: string;
8
+ sequences?: string;
9
+ };
10
+ /** Host collections for the kit a sample came in and the lab that read it. Left out, the field isn't added. */
11
+ relations?: {
12
+ kit?: string;
13
+ lab?: string;
14
+ };
15
+ /** Who may read samples and sequences, besides managers. Default: managers only. */
16
+ readAccess?: Access;
17
+ /** The markers a sequence may be for, with the lengths accepted. Default: any marker, 100 to 50,000 bases. */
18
+ markers?: Record<string, {
19
+ minLength?: number;
20
+ maxLength?: number;
21
+ }>;
22
+ /** The host's tenant field, filled from `registerSequence`'s `tenant` and copied onto results. Default `tenant`. */
23
+ tenantField?: string;
24
+ };
25
+ /** Reads one FASTA file as one sequence, or says in plain words why it can't. */
26
+ declare function readSingleSequence(text: string, marker: string, markers?: RecordsOptions['markers']): {
27
+ recordId: string;
28
+ residues: string;
29
+ };
30
+ /** How a chromatogram read was judged, as stored on its sequence. Never coordinates or anything else from the file. */
31
+ type TraceSummary = {
32
+ status: 'usable';
33
+ keptStart: number;
34
+ keptEnd: number;
35
+ rawLength: number;
36
+ meanQuality: number | null;
37
+ maskedBases: number;
38
+ mixedPeaks: number | null;
39
+ };
40
+ /**
41
+ * Reads one Sanger chromatogram (.ab1) as one sequence: trimmed by quality, with weak bases as N (`assessRead`'s stated
42
+ * defaults). Refuses, in plain words, a file that isn't a readable chromatogram and a read that failed or is too short.
43
+ */
44
+ declare function readTrace(bytes: Uint8Array, marker: string, markers?: RecordsOptions['markers']): {
45
+ recordId: string | null;
46
+ residues: string;
47
+ trace: TraceSummary;
48
+ };
49
+ type RegisterBase = {
50
+ /** The host's tenant (site), written to the tenant field. */
51
+ tenant?: string | number;
52
+ animal: string | number;
53
+ /** Taken from the animal's `taxon` field when left out. */
54
+ taxon?: string | number;
55
+ kit?: string | number;
56
+ lab?: string | number;
57
+ /** The host's file record holding the bytes the lab sent. */
58
+ file?: string | number;
59
+ /** SHA-256 of the file, as the host computed it from the stored bytes. */
60
+ sha256: string;
61
+ marker: string;
62
+ source?: 'kit' | 'upload' | 'historic';
63
+ collectedAt?: string;
64
+ req?: PayloadRequest;
65
+ };
66
+ type RegisterSequenceInput = RegisterBase & {
67
+ /** The file's text. It must hash to `sha256`. */
68
+ text: string;
69
+ };
70
+ type RegisterTraceInput = RegisterBase & {
71
+ /** The chromatogram's bytes. They must hash to `sha256`. */
72
+ bytes: Uint8Array;
73
+ /** Used as the sequence's record ID when the file carries no sample name. */
74
+ fileName?: string;
75
+ };
76
+ /**
77
+ * Records one lab file as a sample and a sequence. It writes with full access, so the caller must already have checked
78
+ * that this person may submit results for this kit. Calling it again with the same kit and file changes nothing.
79
+ */
80
+ declare function registerSequence(payload: Payload, input: RegisterSequenceInput): Promise<Registered>;
81
+ /**
82
+ * Records one Sanger chromatogram (.ab1) as a sample and a sequence, like `registerSequence`. The read is trimmed by
83
+ * quality and its weak bases become N; the kept bases are stored with how the read was judged (`trace`). A file that
84
+ * isn't a chromatogram, or a read that failed or is too short, is refused and nothing is stored. The same access rule
85
+ * applies: check first that the caller may submit results for this kit.
86
+ */
87
+ declare function registerTrace(payload: Payload, input: RegisterTraceInput): Promise<Registered>;
88
+ type Registered = {
89
+ sample: Record<string, unknown>;
90
+ sequence: Record<string, unknown>;
91
+ created: boolean;
92
+ };
93
+ /** What `assignWaiting` asks the host to compute for one sequence against one panel. */
94
+ /**
95
+ * Tests one sequence. `{ skip }` means the panel itself can't be used right now (for example its examples no longer give
96
+ * the answers they gave when it was built): the sequence stays waiting, and the skip is reported, never held against it.
97
+ */
98
+ type Evaluate = (args: {
99
+ residues: string;
100
+ queryId: string;
101
+ panel: Record<string, unknown>;
102
+ }) => Promise<{
103
+ result: Result | null;
104
+ problems: string[];
105
+ } | {
106
+ skip: string;
107
+ }>;
108
+ /** A short, plain summary of a result, naming the groups it is consistent with. */
109
+ declare function summarize(result: Result, panel: {
110
+ groups?: {
111
+ groupId: string;
112
+ label: string;
113
+ }[];
114
+ }): string;
115
+ /**
116
+ * The sweep: tests each sequence still `received` against the panel for its marker and species, and records a result
117
+ * waiting for review. A sequence with no panel stays waiting; one the checks refuse is marked not assessable, with why. A
118
+ * panel `evaluate` skips leaves its sequences waiting, and is listed in `skippedPanels` so the run can say so.
119
+ */
120
+ declare function assignWaiting(payload: Payload, args: {
121
+ evaluate: Evaluate;
122
+ limit?: number;
123
+ req?: PayloadRequest;
124
+ }): Promise<{
125
+ checked: number;
126
+ skippedPanels: {
127
+ panel: string;
128
+ key: string;
129
+ version: string;
130
+ reason: string;
131
+ }[];
132
+ assigned: number;
133
+ notAssessable: number;
134
+ noPanel: number;
135
+ skipped: number;
136
+ }>;
137
+
138
+ type Granted = boolean | Where;
139
+ /**
140
+ * Joins access results with "or". A rule may grant everything (`true`), nothing, or only matching records (a query), and
141
+ * a query is never read as everything: a reviewer of one site sees that site's records, not all of them.
142
+ */
143
+ declare function either(...grants: (Granted | null | undefined)[]): Granted;
144
+ /** Access that allows what any of the given rules allows. */
145
+ declare const anyOf: (...rules: (Access | undefined)[]) => Access;
146
+
147
+ type OnePhylogenyPluginOptions = {
148
+ /** Slugs of the collections this plugin adds. */
149
+ slugs?: {
150
+ panels?: string;
151
+ assignments?: string;
152
+ };
153
+ /** Host collections to relate to. Leave one out and its field isn't added, so the plugin works in any site. */
154
+ relations?: {
155
+ subject?: string;
156
+ sequence?: string;
157
+ taxa?: string;
158
+ files?: string;
159
+ importRuns?: string;
160
+ };
161
+ /** Who may create panels and results, and activate panels. Default: nobody but trusted local scripts. Activating also needs a signed-in user, who is recorded. */
162
+ manageAccess?: Access;
163
+ /** Who may approve or reject results. Default: same as manageAccess. */
164
+ reviewAccess?: Access;
165
+ /** Extra rule for reading released results, such as the host's own animal permissions. Default: signed-in users. */
166
+ readReleasedAccess?: Access;
167
+ /** Field added to assignments for multi-tenant hosts' isolation plugins to find. */
168
+ group?: string;
169
+ /**
170
+ * Which panels results may be made against. `activeOrShown` also allows a `candidate` a maintainer ticked "shown as
171
+ * exploratory", and lets readers see such candidates. Default: `active`.
172
+ */
173
+ resultsAgainst?: 'active' | 'activeOrShown';
174
+ /**
175
+ * Adds `samples` and `sequences`, with `registerSequence` to record a lab's file and `assignWaiting` to test waiting
176
+ * sequences. Left out, neither collection is added. Results then relate to these sequences.
177
+ */
178
+ records?: RecordsOptions;
179
+ /**
180
+ * The host's tenant (site) field on results, if it has one, such as a multi-tenant plugin adds. A result's site is set
181
+ * when it is made and can't change, so a reviewer can't move it to a site whose people would then see it. Default `tenant`.
182
+ */
183
+ tenantField?: string;
184
+ };
185
+
186
+ /**
187
+ * OnePhylogeny for Payload. Adds immutable panels and reviewed results, relating to whatever collections a site already
188
+ * has. It holds no species knowledge. Compute happens elsewhere: this stores what was computed and controls release.
189
+ */
190
+ declare const onePhylogeny: (options?: OnePhylogenyPluginOptions) => Plugin;
191
+
192
+ export { type Evaluate, type OnePhylogenyPluginOptions, type RecordsOptions, type RegisterSequenceInput, type RegisterTraceInput, type TraceSummary, anyOf, assignWaiting, either, onePhylogeny, readSingleSequence, readTrace, registerSequence, registerTrace, summarize };
package/dist/index.js ADDED
@@ -0,0 +1,477 @@
1
+ // src/index.ts
2
+ import { validateResult } from "@extantape/onephylogeny-core";
3
+ import { relationship as validateRelationship } from "payload/shared";
4
+
5
+ // src/access.ts
6
+ function either(...grants) {
7
+ if (grants.some((g) => g === true)) return true;
8
+ const queries = grants.filter((g) => Boolean(g) && typeof g === "object");
9
+ return queries.length === 0 ? false : queries.length === 1 ? queries[0] : { or: queries };
10
+ }
11
+ var anyOf = (...rules) => async (args) => either(...await Promise.all(rules.map((r) => r ? r(args) : false)));
12
+
13
+ // src/records.ts
14
+ import { assessRead, ChromatogramError, parseFasta, readAbif, sha256Hex, sha256HexBytes } from "@extantape/onephylogeny-core";
15
+ import { APIError } from "payload";
16
+ var CUSTOM_KEY = "onePhylogenyRecords";
17
+ var DNA = /^[ACGTRYKMSWBDHVN]+$/;
18
+ var DEFAULT_LENGTH = { minLength: 100, maxLength: 5e4 };
19
+ var fail = (message) => {
20
+ throw new APIError(message, 400, void 0, true);
21
+ };
22
+ var idOf = (v) => v && typeof v === "object" ? String(v.id) : v == null ? void 0 : String(v);
23
+ var relation = (name, relationTo, extra = {}) => relationTo ? [{ name, type: "relationship", relationTo, index: true, ...extra }] : [];
24
+ var comparable = (v) => {
25
+ if (v == null) return null;
26
+ if (typeof v !== "object") return String(v);
27
+ if (Array.isArray(v)) return v.map(comparable);
28
+ if ("id" in v) return String(v.id);
29
+ const set = Object.entries(v).filter(([, x]) => x != null).sort(([a], [b]) => a.localeCompare(b));
30
+ return set.length ? Object.fromEntries(set.map(([k, x]) => [k, comparable(x)])) : null;
31
+ };
32
+ var locked = (fields, message) => ({ data, originalDoc, operation }) => {
33
+ if (operation === "update") {
34
+ for (const f of fields) if (f in data && JSON.stringify(comparable(data[f])) !== JSON.stringify(comparable(originalDoc[f]))) fail(message);
35
+ }
36
+ return data;
37
+ };
38
+ function recordCollections(o, base) {
39
+ const samples = o.slugs?.samples ?? "samples";
40
+ const sequences = o.slugs?.sequences ?? "sequences";
41
+ const manage = base.manage;
42
+ const read = anyOf(manage, o.readAccess);
43
+ const access = { read, create: manage, update: manage, delete: () => false };
44
+ const tenantField = o.tenantField ?? "tenant";
45
+ const sampleCollection = {
46
+ slug: samples,
47
+ labels: { singular: "Sample", plural: "Samples" },
48
+ admin: { group: "Genetics", defaultColumns: ["subject", "source", "kit", "createdAt"] },
49
+ access,
50
+ fields: [
51
+ ...relation("subject", base.subject, { required: true }),
52
+ ...relation("kit", o.relations?.kit),
53
+ ...relation("taxon", base.taxa),
54
+ { name: "source", type: "select", required: true, defaultValue: "kit", options: ["kit", "upload", "historic"] },
55
+ { name: "material", type: "text", admin: { description: "What was sampled, such as a shell scrape or blood." } },
56
+ { name: "collectedAt", type: "date" },
57
+ { name: "consent", type: "text", admin: { description: "The keeper's consent, as recorded with the kit or upload." } }
58
+ ],
59
+ hooks: { beforeChange: [locked(["subject", "kit", "source", tenantField], "A sample's animal, kit, source and site can't change. Record a new sample instead.")] }
60
+ };
61
+ const sequenceCollection = {
62
+ slug: sequences,
63
+ labels: { singular: "Sequence", plural: "Sequences" },
64
+ admin: { group: "Genetics", useAsTitle: "recordId", defaultColumns: ["recordId", "marker", "status", "length", "createdAt"] },
65
+ access,
66
+ fields: [
67
+ { name: "sample", type: "relationship", relationTo: samples, required: true, index: true },
68
+ { name: "marker", type: "text", required: true, index: true },
69
+ ...relation("lab", o.relations?.lab),
70
+ ...relation("file", base.files, { admin: { description: "The file the lab sent. It stays the record of what was received." } }),
71
+ { name: "sha256", type: "text", required: true, index: true, admin: { description: "SHA-256 of the file, checked against its text when it was registered." } },
72
+ { name: "recordId", type: "text", admin: { description: "The FASTA header the lab gave this sequence." } },
73
+ { name: "residues", type: "textarea", required: true, admin: { description: "The bases, cleaned of gaps and line breaks. Used for analysis." } },
74
+ { name: "length", type: "number", required: true },
75
+ { name: "status", type: "select", required: true, defaultValue: "received", index: true, options: ["received", "assigned", "not-assessable"] },
76
+ { name: "statusReason", type: "text", admin: { description: "Why it couldn't be assessed, in plain words." } },
77
+ {
78
+ name: "trace",
79
+ type: "group",
80
+ admin: { description: "Set when the sequence came from a Sanger chromatogram (.ab1): how the read was judged. Empty for FASTA." },
81
+ fields: [
82
+ { name: "status", type: "select", options: ["usable"], admin: { description: "Only usable reads are stored; failed and too-short reads are refused." } },
83
+ { name: "keptStart", type: "number", admin: { description: "First kept base of the raw read, counting from 1." } },
84
+ { name: "keptEnd", type: "number", admin: { description: "Last kept base of the raw read." } },
85
+ { name: "rawLength", type: "number" },
86
+ { name: "meanQuality", type: "number", admin: { description: "Mean Phred quality of the kept bases." } },
87
+ { name: "maskedBases", type: "number", admin: { description: "Kept bases below Q20, stored as N." } },
88
+ { name: "mixedPeaks", type: "number", admin: { description: "Positions with a strong second peak. Empty when the file has no traces to check." } }
89
+ ]
90
+ }
91
+ ],
92
+ hooks: { beforeChange: [locked(["sample", "marker", "file", "sha256", "residues", "recordId", "length", "trace", tenantField], "A sequence can't be edited. Register the corrected file instead.")] }
93
+ };
94
+ const config = {
95
+ samples,
96
+ sequences,
97
+ panels: base.panels,
98
+ assignments: base.assignments,
99
+ tenantField,
100
+ markers: o.markers,
101
+ subject: base.subject,
102
+ hasTaxa: Boolean(base.taxa),
103
+ hasKit: Boolean(o.relations?.kit),
104
+ hasLab: Boolean(o.relations?.lab),
105
+ hasFiles: Boolean(base.files),
106
+ againstShown: base.againstShown
107
+ };
108
+ return { collections: [sampleCollection, sequenceCollection], config, customKey: CUSTOM_KEY };
109
+ }
110
+ var configOf = (payload) => {
111
+ const c = payload.config.custom?.[CUSTOM_KEY];
112
+ if (!c) throw new Error("OnePhylogeny samples and sequences aren't turned on. Pass `records` to the plugin.");
113
+ return c;
114
+ };
115
+ function readSingleSequence(text, marker, markers) {
116
+ if (markers && !markers[marker]) fail(`This site doesn't test the marker "${marker}".`);
117
+ let entries;
118
+ try {
119
+ entries = parseFasta(text.replace(/^/, ""));
120
+ } catch {
121
+ return fail(`This file isn't FASTA: it has bases before the first ">" header line.`);
122
+ }
123
+ if (!entries.length) fail(`This file is empty or has no ">" header line, so it isn't FASTA.`);
124
+ if (entries.length > 1) fail(`This file holds ${entries.length} sequences. Send one file per kit, with one sequence in it.`);
125
+ const entry = entries[0];
126
+ return { recordId: entry.id, residues: checkResidues(entry.sequence.replace(/[\s\-.]/g, "").toUpperCase(), marker, markers) };
127
+ }
128
+ function checkResidues(residues, marker, markers) {
129
+ if (markers && !markers[marker]) fail(`This site doesn't test the marker "${marker}".`);
130
+ const { minLength, maxLength } = { ...DEFAULT_LENGTH, ...markers?.[marker] };
131
+ if (!residues) fail("This file's sequence is empty.");
132
+ if (!DNA.test(residues)) {
133
+ const bad = [...new Set(residues.replace(/[ACGTRYKMSWBDHVN]/g, ""))].slice(0, 5).join(" ");
134
+ fail(`This sequence has characters that aren't DNA bases: ${bad}.`);
135
+ }
136
+ if (residues.length < minLength) fail(`This sequence is ${residues.length} bases long, shorter than the ${minLength} needed for ${marker}.`);
137
+ if (residues.length > maxLength) fail(`This sequence is ${residues.length} bases long, longer than the ${maxLength} expected for ${marker}.`);
138
+ const unresolved = (residues.match(/[^ACGT]/g) ?? []).length;
139
+ if (unresolved > residues.length / 2) fail(`More than half of this sequence's bases are unresolved (${unresolved} of ${residues.length}).`);
140
+ return residues;
141
+ }
142
+ function readTrace(bytes, marker, markers) {
143
+ let read;
144
+ try {
145
+ read = readAbif(bytes);
146
+ } catch (e) {
147
+ return fail(e instanceof ChromatogramError ? `${e.message}.` : "This file couldn't be read as a chromatogram (.ab1).");
148
+ }
149
+ const a = assessRead(read);
150
+ if (a.status === "failed") fail(`This read failed, so it isn't stored or tested. ${a.notes[0]}`);
151
+ if (a.status === "short") fail(`This read is too short to use: only ${a.sequence.length} bases are good enough, under the ${a.settings.minLength} needed. It isn't stored or tested.`);
152
+ const residues = checkResidues(a.sequence, marker, markers);
153
+ return {
154
+ recordId: read.sampleName,
155
+ residues,
156
+ trace: { status: "usable", keptStart: a.kept.start + 1, keptEnd: a.kept.end, rawLength: a.rawLength, meanQuality: a.meanQuality, maskedBases: a.maskedBases, mixedPeaks: a.mixedPeaks ? a.mixedPeaks.length : null }
157
+ };
158
+ }
159
+ function registerSequence(payload, input) {
160
+ return register(payload, input, (sha256) => {
161
+ if (sha256Hex(input.text) !== sha256) fail("This file's text doesn't match its SHA-256. It may have changed after upload; upload it again.");
162
+ return readSingleSequence(input.text, input.marker, configOf(payload).markers);
163
+ });
164
+ }
165
+ function registerTrace(payload, input) {
166
+ return register(payload, input, (sha256) => {
167
+ if (sha256HexBytes(input.bytes) !== sha256) fail("This file doesn't match its SHA-256. It may have changed after upload; upload it again.");
168
+ const { recordId, residues, trace } = readTrace(input.bytes, input.marker, configOf(payload).markers);
169
+ return { recordId: recordId ?? input.fileName ?? "chromatogram", residues, trace };
170
+ });
171
+ }
172
+ async function register(payload, input, read) {
173
+ const c = configOf(payload);
174
+ const opts = { req: input.req, overrideAccess: true, depth: 0 };
175
+ const sha256 = input.sha256.replace(/^sha256:/i, "").toLowerCase();
176
+ if (!/^[0-9a-f]{64}$/.test(sha256)) fail("The file's SHA-256 is missing or malformed.");
177
+ const { recordId, residues, trace } = read(sha256);
178
+ if ((input.source ?? "kit") === "kit" && input.kit == null) fail("A kit sample needs its kit.");
179
+ if (input.animal == null || input.animal === "") fail("This kit isn't linked to an animal yet. It has to be activated first.");
180
+ let taxon = input.taxon;
181
+ if (taxon == null && c.hasTaxa) {
182
+ const subject = c.subject ? await payload.findByID({ collection: c.subject, id: input.animal, ...opts }).catch(() => null) : null;
183
+ taxon = idOf(subject?.taxon);
184
+ }
185
+ if (c.hasTaxa && taxon == null) fail("This animal has no species recorded, so its sequence can't be matched to a panel.");
186
+ let sample;
187
+ if (input.kit != null && c.hasKit) {
188
+ sample = (await payload.find({ collection: c.samples, where: { kit: { equals: input.kit } }, limit: 1, ...opts })).docs[0];
189
+ if (sample && idOf(sample.subject) !== String(input.animal)) fail("This kit is already recorded for another animal.");
190
+ }
191
+ if (sample) {
192
+ const existing = (await payload.find({ collection: c.sequences, where: { and: [{ sample: { equals: sample.id } }, { sha256: { equals: sha256 } }] }, limit: 1, ...opts })).docs[0];
193
+ if (existing) return { sample, sequence: existing, created: false };
194
+ } else {
195
+ sample = await payload.create({ collection: c.samples, data: {
196
+ ...c.subject ? { subject: input.animal } : {},
197
+ ...c.hasKit && input.kit != null ? { kit: input.kit } : {},
198
+ ...c.hasTaxa ? { taxon } : {},
199
+ source: input.source ?? "kit",
200
+ ...input.collectedAt ? { collectedAt: input.collectedAt } : {},
201
+ ...input.tenant != null ? { [c.tenantField]: input.tenant } : {}
202
+ }, ...opts });
203
+ }
204
+ const sequence = await payload.create({ collection: c.sequences, data: {
205
+ sample: sample.id,
206
+ marker: input.marker,
207
+ sha256,
208
+ recordId,
209
+ residues,
210
+ length: residues.length,
211
+ status: "received",
212
+ ...trace ? { trace } : {},
213
+ ...c.hasLab && input.lab != null ? { lab: input.lab } : {},
214
+ ...c.hasFiles && input.file != null ? { file: input.file } : {},
215
+ ...input.tenant != null ? { [c.tenantField]: input.tenant } : {}
216
+ }, ...opts });
217
+ return { sample, sequence, created: true };
218
+ }
219
+ function summarize(result, panel) {
220
+ const label = (id) => panel.groups?.find((g) => g.groupId === id)?.label ?? id;
221
+ const consistent = result.findings.filter((f) => f.status === "consistent").map((f) => label(f.group));
222
+ if (consistent.length === 1) return `Consistent with ${consistent[0]}`;
223
+ if (consistent.length > 1) return `Consistent with ${consistent.slice(0, -1).join(", ")} or ${consistent.at(-1)}`;
224
+ return "No single lineage";
225
+ }
226
+ async function assignWaiting(payload, args) {
227
+ const c = configOf(payload);
228
+ const opts = { req: args.req, overrideAccess: true, depth: 0 };
229
+ const tally = { assigned: 0, notAssessable: 0, noPanel: 0, skipped: 0 };
230
+ const skippedPanels = /* @__PURE__ */ new Map();
231
+ const waiting = await payload.find({ collection: c.sequences, where: { status: { equals: "received" } }, sort: "createdAt", limit: args.limit ?? 200, ...opts });
232
+ const usable = c.againstShown ? { or: [{ status: { equals: "active" } }, { and: [{ status: { equals: "candidate" } }, { shownAsExploratory: { equals: true } }] }] } : { status: { equals: "active" } };
233
+ for (const seq of waiting.docs) {
234
+ const sample = await payload.findByID({ collection: c.samples, id: idOf(seq.sample), ...opts });
235
+ const taxon = idOf(sample.taxon);
236
+ const found = await payload.find({ collection: c.panels, where: { and: [{ marker: { equals: seq.marker } }, usable] }, sort: "-createdAt", limit: 50, ...opts });
237
+ const fits = found.docs.filter((p) => !c.hasTaxa || !p.taxa?.length || p.taxa.map(idOf).includes(taxon));
238
+ const panel = fits.find((p) => p.status === "active") ?? fits[0];
239
+ if (!panel) {
240
+ tally.noPanel++;
241
+ continue;
242
+ }
243
+ const already = await payload.find({ collection: c.assignments, where: { and: [{ sequence: { equals: seq.id } }, { panel: { equals: panel.id } }] }, limit: 1, ...opts });
244
+ if (already.docs.length) {
245
+ await payload.update({ collection: c.sequences, id: seq.id, data: { status: "assigned" }, ...opts });
246
+ continue;
247
+ }
248
+ const outcome = await args.evaluate({ residues: String(seq.residues), queryId: String(seq.id), panel });
249
+ if ("skip" in outcome) {
250
+ tally.skipped++;
251
+ skippedPanels.set(String(panel.id), { panel: String(panel.id), key: String(panel.key), version: String(panel.version), reason: outcome.skip });
252
+ continue;
253
+ }
254
+ const { result, problems } = outcome;
255
+ if (!result) {
256
+ await payload.update({ collection: c.sequences, id: seq.id, data: { status: "not-assessable", statusReason: (problems.join("; ") || "The panel's checks refused this sequence.").slice(0, 1e3) }, ...opts });
257
+ tally.notAssessable++;
258
+ continue;
259
+ }
260
+ const tenant = sample[c.tenantField];
261
+ await payload.create({ collection: c.assignments, data: {
262
+ ...c.subject ? { subject: idOf(sample.subject) } : {},
263
+ sequence: seq.id,
264
+ panel: panel.id,
265
+ summary: summarize(result, panel),
266
+ result,
267
+ ...tenant != null ? { [c.tenantField]: idOf(tenant) } : {}
268
+ }, ...opts });
269
+ await payload.update({ collection: c.sequences, id: seq.id, data: { status: "assigned" }, ...opts });
270
+ tally.assigned++;
271
+ }
272
+ return { ...tally, checked: waiting.docs.length, skippedPanels: [...skippedPanels.values()] };
273
+ }
274
+
275
+ // src/index.ts
276
+ import { APIError as APIError2 } from "payload";
277
+ var PANEL_TRANSITIONS = { candidate: ["active", "withdrawn"], active: ["superseded", "withdrawn"], superseded: ["withdrawn"], withdrawn: [] };
278
+ var LOCKED_PANEL_FIELDS = ["key", "version", "marker", "checksum", "artifact", "importRun", "taxa", "groups", "notCovered", "validatedScope"];
279
+ var REVIEW_TRANSITIONS = { pending: ["approved", "rejected"], approved: ["withdrawn"], rejected: [], withdrawn: [] };
280
+ var COORDINATES = /^(lat|lon|lng|latitude|longitude|latlon|lat_lon|coordinates?)$/i;
281
+ var hasCoordinates = (value) => {
282
+ if (Array.isArray(value)) return value.some(hasCoordinates);
283
+ if (!value || typeof value !== "object") return false;
284
+ return Object.entries(value).some(([k, v]) => COORDINATES.test(k) || hasCoordinates(v));
285
+ };
286
+ var fail2 = (message) => {
287
+ throw new APIError2(message, 400, void 0, true);
288
+ };
289
+ var idOf2 = (v) => v && typeof v === "object" ? String(v.id) : v == null ? void 0 : String(v);
290
+ var same = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
291
+ var stripIds = (rows) => Array.isArray(rows) ? rows.map((r) => {
292
+ const { id: _id, ...rest } = r;
293
+ return rest;
294
+ }) : rows;
295
+ var stamp = (v) => v == null || v === "" ? "" : v instanceof Date ? v.toISOString() : String(v);
296
+ var ACTIVATION_FIELDS = ["activatedBy", "activatedAt"];
297
+ var panelBeforeChange = ({ data, originalDoc, operation, req }) => {
298
+ const leaving = operation === "update" && String(data.status ?? originalDoc.status) !== "candidate";
299
+ if (leaving) {
300
+ if (data.shownAsExploratory === true && String(originalDoc.status) !== "candidate") fail2("Only a candidate panel can be shown as exploratory.");
301
+ data.shownAsExploratory = false;
302
+ }
303
+ if (hasCoordinates(data.groups)) fail2("Panels use generalized regions and never hold coordinates.");
304
+ if (operation === "create") {
305
+ if ((data.status ?? "candidate") !== "candidate") fail2("A new panel starts as a candidate.");
306
+ if (ACTIVATION_FIELDS.some((f) => stamp(data[f]))) fail2("Who activated a panel, and when, are set by activating.");
307
+ return data;
308
+ }
309
+ const from = String(originalDoc.status);
310
+ const to = String(data.status ?? from);
311
+ if (to !== from && !PANEL_TRANSITIONS[from]?.includes(to)) fail2(`A panel can't go from ${from} to ${to}.`);
312
+ if (from === "candidate" && to === "active") {
313
+ if (!(data.validatedScope ?? originalDoc.validatedScope)?.length) fail2("A panel with no validated claims can't become active.");
314
+ if (!req.user) fail2("Activating a panel needs a signed-in person, who is recorded.");
315
+ data.activatedBy = String(req.user.id);
316
+ data.activatedAt = (/* @__PURE__ */ new Date()).toISOString();
317
+ } else if (ACTIVATION_FIELDS.some((f) => f in data && stamp(data[f]) !== stamp(originalDoc[f]))) {
318
+ fail2("Who activated a panel, and when, are set by activating.");
319
+ }
320
+ if (from !== "candidate") {
321
+ for (const f of LOCKED_PANEL_FIELDS) {
322
+ if (!(f in data)) continue;
323
+ const changed = f === "groups" ? !same(stripIds(data[f]), stripIds(originalDoc[f])) : Array.isArray(data[f]) ? !same(data[f].map(idOf2), (originalDoc[f] ?? []).map(idOf2)) : idOf2(data[f]) !== idOf2(originalDoc[f]);
324
+ if (changed) fail2(`A ${from} panel can't be edited. Build a new version instead.`);
325
+ }
326
+ }
327
+ return data;
328
+ };
329
+ var supersedeOthers = (panels) => async ({ doc, previousDoc, req }) => {
330
+ if (doc.status !== "active" || previousDoc?.status === "active") return doc;
331
+ const others = await req.payload.find({ collection: panels, where: { and: [{ key: { equals: doc.key } }, { status: { equals: "active" } }, { id: { not_equals: doc.id } }] }, limit: 100, depth: 0, req, overrideAccess: true });
332
+ for (const other of others.docs) await req.payload.update({ collection: panels, id: other.id, data: { status: "superseded" }, req, overrideAccess: true });
333
+ return doc;
334
+ };
335
+ var assignmentBeforeChange = (panels, againstShown, tenantField) => async ({ data, originalDoc, operation, req }) => {
336
+ if (operation === "create") {
337
+ if ((data.reviewStatus ?? "pending") !== "pending") fail2("A new result starts as pending review.");
338
+ const panel = await req.payload.findByID({ collection: panels, id: idOf2(data.panel), depth: 0, req, overrideAccess: true });
339
+ const shown = panel.status === "candidate" && panel.shownAsExploratory === true;
340
+ if (panel.status !== "active" && !(againstShown && shown)) fail2(againstShown ? "Results can only be made against an active panel, or a candidate shown as exploratory." : "Results can only be made against an active panel.");
341
+ data.panelStatus = panel.status;
342
+ data.panelShownAsExploratory = shown;
343
+ const result = data.result;
344
+ const problems = validateResult(result).filter((d) => d.severity === "error");
345
+ if (problems.length) fail2(problems.map((p) => p.message).join("; "));
346
+ if (result.panel.version !== panel.version || result.panel.checksum !== panel.checksum) fail2("This result was not made with this panel version.");
347
+ const found = new Set(result.findings.map((f) => f.group));
348
+ const missing = (panel.groups ?? []).filter((g) => !found.has(g.groupId)).map((g) => g.groupId);
349
+ if (missing.length) fail2(`Every group must be reported. Missing: ${missing.join(", ")}.`);
350
+ if (hasCoordinates(result)) fail2("Results never hold coordinates.");
351
+ return data;
352
+ }
353
+ const from = String(originalDoc.reviewStatus);
354
+ const to = String(data.reviewStatus ?? from);
355
+ for (const f of ["result", "panel", "sequence", "subject", "summary", "importRun"]) {
356
+ if (f in data && (f === "result" || f === "summary" ? !same(data[f], originalDoc[f]) : idOf2(data[f]) !== idOf2(originalDoc[f]))) fail2("A result can't be edited. Make a new one instead.");
357
+ }
358
+ if (tenantField in data && idOf2(data[tenantField]) !== idOf2(originalDoc[tenantField])) fail2("A result stays on the site it was made for.");
359
+ for (const f of ["panelStatus", "panelShownAsExploratory"]) {
360
+ if (f in data && !same(data[f], originalDoc[f])) fail2("The panel status a result was made against is set when it is made.");
361
+ }
362
+ if (to !== from) {
363
+ if (!REVIEW_TRANSITIONS[from]?.includes(to)) fail2(`A result can't go from ${from} to ${to}.`);
364
+ if (to === "approved") {
365
+ if (!req.user) fail2("Approving a result needs a signed-in reviewer.");
366
+ data.reviewer = String(req.user.id);
367
+ data.releasedAt = (/* @__PURE__ */ new Date()).toISOString();
368
+ }
369
+ } else {
370
+ if ("reviewer" in data && data.reviewer !== originalDoc.reviewer) fail2("The reviewer is set by approving.");
371
+ if ("releasedAt" in data && String(data.releasedAt) !== String(originalDoc.releasedAt)) fail2("The release date is set by approving.");
372
+ }
373
+ return data;
374
+ };
375
+ var relation2 = (name, relationTo, extra = {}) => relationTo ? [{ name, type: "relationship", relationTo, index: true, ...extra }] : [];
376
+ var checkedWhenMade = { validate: (value, options) => options.operation === "update" ? true : validateRelationship(value, options) };
377
+ var onePhylogeny = (options = {}) => (config) => {
378
+ const panels = options.slugs?.panels ?? "panels";
379
+ const assignments = options.slugs?.assignments ?? "assignments";
380
+ const tenantField = options.tenantField ?? options.records?.tenantField ?? "tenant";
381
+ const records = options.records ? recordCollections({ tenantField, ...options.records }, { panels, assignments, subject: options.relations?.subject, taxa: options.relations?.taxa, files: options.relations?.files, manage: options.manageAccess ?? (() => false), againstShown: options.resultsAgainst === "activeOrShown" }) : void 0;
382
+ const r = { ...options.relations, ...records && !options.relations?.sequence ? { sequence: records.config.sequences } : {} };
383
+ const group = options.group ?? "Genetics";
384
+ const manage = options.manageAccess ?? (() => false);
385
+ const review = options.reviewAccess ?? manage;
386
+ const readReleased = options.readReleasedAccess ?? (({ req }) => Boolean(req.user));
387
+ const againstShown = options.resultsAgainst === "activeOrShown";
388
+ const panelCollection = {
389
+ slug: panels,
390
+ labels: { singular: "Reference panel", plural: "Reference panels" },
391
+ admin: { group, useAsTitle: "key", defaultColumns: ["key", "version", "status", "marker"] },
392
+ access: {
393
+ read: async (args) => {
394
+ const published = { status: { in: ["active", "superseded"] } };
395
+ const shown = { and: [{ status: { equals: "candidate" } }, { shownAsExploratory: { equals: true } }] };
396
+ return either(await manage(args), published, againstShown ? shown : false);
397
+ },
398
+ create: manage,
399
+ update: manage,
400
+ delete: () => false
401
+ },
402
+ fields: [
403
+ { name: "key", type: "text", required: true, index: true, admin: { description: "Stays the same across versions of one panel." } },
404
+ { name: "version", type: "text", required: true },
405
+ { name: "status", type: "select", required: true, defaultValue: "candidate", index: true, options: ["candidate", "active", "superseded", "withdrawn"] },
406
+ { name: "shownAsExploratory", type: "checkbox", defaultValue: false, index: true, admin: { description: "Show this candidate as exploratory, before review. Only candidates; cleared when it moves on." } },
407
+ { name: "marker", type: "text", required: true },
408
+ { name: "checksum", type: "text", required: true, index: true },
409
+ ...relation2("taxa", r.taxa, { hasMany: true }),
410
+ ...relation2("artifact", r.files, { admin: { description: "The full panel: JSON manifest and sequences." } }),
411
+ ...relation2("importRun", r.importRuns),
412
+ { name: "validatedScope", type: "text", hasMany: true, admin: { description: "The claims this panel is validated for. Pages show only these." } },
413
+ { name: "notCovered", type: "text", hasMany: true },
414
+ { name: "groups", type: "array", fields: [{ name: "groupId", type: "text", required: true }, { name: "label", type: "text", required: true }, { name: "regionName", type: "text", admin: { description: "A general region, never coordinates." } }] },
415
+ { name: "activatedBy", type: "text", admin: { readOnly: true, description: "The signed-in user who activated this panel. Set by activating." } },
416
+ { name: "activatedAt", type: "date", admin: { readOnly: true } }
417
+ ],
418
+ hooks: { beforeChange: [panelBeforeChange], afterChange: [supersedeOthers(panels)] }
419
+ };
420
+ const assignmentCollection = {
421
+ slug: assignments,
422
+ labels: { singular: "Lineage result", plural: "Lineage results" },
423
+ admin: { group, useAsTitle: "summary", defaultColumns: ["summary", "panel", "reviewStatus", "releasedAt"] },
424
+ access: {
425
+ // Managers and reviewers see what their own rules allow, including pending results; everyone else only released ones.
426
+ read: async (args) => {
427
+ const released2 = { reviewStatus: { equals: "approved" } };
428
+ const allowed = await readReleased(args);
429
+ return either(await manage(args), await review(args), allowed === true ? released2 : allowed ? { and: [released2, allowed] } : false);
430
+ },
431
+ create: manage,
432
+ update: review,
433
+ delete: () => false
434
+ },
435
+ fields: [
436
+ ...relation2("subject", r.subject, checkedWhenMade),
437
+ ...relation2("sequence", r.sequence, checkedWhenMade),
438
+ { name: "panel", type: "relationship", relationTo: panels, required: true, index: true, ...checkedWhenMade },
439
+ { name: "summary", type: "text", required: true },
440
+ { name: "result", type: "json", required: true, admin: { description: "The OnePhylogeny result, stored exactly as computed." } },
441
+ ...relation2("importRun", r.importRuns, checkedWhenMade),
442
+ { name: "reviewStatus", type: "select", required: true, defaultValue: "pending", index: true, options: ["pending", "approved", "rejected", "withdrawn"] },
443
+ { name: "reviewer", type: "text", admin: { readOnly: true } },
444
+ { name: "releasedAt", type: "date", admin: { readOnly: true } },
445
+ { name: "panelStatus", type: "text", admin: { readOnly: true, description: "The panel's status when this result was made." } },
446
+ { name: "panelShownAsExploratory", type: "checkbox", admin: { readOnly: true } }
447
+ ],
448
+ hooks: { beforeChange: [assignmentBeforeChange(panels, againstShown, tenantField)] }
449
+ };
450
+ const released = {
451
+ path: "/onephylogeny/released",
452
+ method: "get",
453
+ handler: async (req) => {
454
+ const subject = new URL(req.url ?? "", "http://x").searchParams.get("subject");
455
+ if (!subject || !r.subject) return Response.json({ error: "A subject is required" }, { status: 400 });
456
+ const found = await req.payload.find({ collection: assignments, where: { and: [{ subject: { equals: subject } }, { reviewStatus: { equals: "approved" } }] }, sort: "-releasedAt", limit: 20, depth: 1, req, overrideAccess: false });
457
+ return Response.json({ docs: found.docs });
458
+ }
459
+ };
460
+ return {
461
+ ...config,
462
+ collections: [...config.collections ?? [], ...records?.collections ?? [], panelCollection, assignmentCollection],
463
+ endpoints: [...config.endpoints ?? [], released],
464
+ ...records ? { custom: { ...config.custom, [records.customKey]: records.config } } : {}
465
+ };
466
+ };
467
+ export {
468
+ anyOf,
469
+ assignWaiting,
470
+ either,
471
+ onePhylogeny,
472
+ readSingleSequence,
473
+ readTrace,
474
+ registerSequence,
475
+ registerTrace,
476
+ summarize
477
+ };
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@extantape/payload-plugin-onephylogeny",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.8",
4
+ "description": "OnePhylogeny for Payload: immutable reference panels and released results on your own collections, with server-enforced review, safe endpoints and no coordinates.",
5
+ "keywords": [
6
+ "phylogenetics",
7
+ "reference-panel"
8
+ ],
9
+ "homepage": "https://github.com/ExtantApe/OnePhylogeny#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/ExtantApe/OnePhylogeny/issues"
12
+ },
13
+ "license": "PolyForm-Noncommercial-1.0.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/ExtantApe/OnePhylogeny.git",
17
+ "directory": "packages/payload"
18
+ },
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "engines": {
35
+ "node": ">=22"
36
+ },
37
+ "dependencies": {
38
+ "@extantape/onephylogeny-core": "^0.1.0-alpha.8"
39
+ },
40
+ "peerDependencies": {
41
+ "payload": "^3.80.0"
42
+ },
43
+ "devDependencies": {
44
+ "@payloadcms/db-mongodb": "3.92.1",
45
+ "graphql": "^16.14.2",
46
+ "mongodb-memory-server": "^11.3.0",
47
+ "payload": "^3.92.1",
48
+ "@types/node": "^24.19.2"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup src/index.ts --format esm --dts --clean --target es2022",
52
+ "typecheck": "tsc --noEmit",
53
+ "test": "vitest run"
54
+ }
6
55
  }