app/kb/procedures/lineage.server.ts
19 lines and 2 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| lineageFor | 12 to 21 | 7 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
| <anonymous:15> | 15 to 15 | 1 | No data: no coverage report in this map | No data: no coverage report in this map | No data: no mutants in this code |
Imports
It imports app/db/procedure-versions.ts, app/db/procedures.ts, app/kb/bases.mjs, app/kb/procedures/lineage.mjs, app/kb/procedures/render.mjs. Imported by app/routes/procedure.tsx, app/routes/procedure.version.tsx, app/routes/procedure.version[.md].ts, app/routes/procedure[.md].ts.
Source
import { getFrozenVersion } from "~/db/procedure-versions";
import { getProcedureByPath } from "~/db/procedures";
import { BASES } from "~/kb/bases.mjs";
import { resolveLineage } from "./lineage.mjs";
import type { ProcedureRecord } from "./render.mjs";
/**
* A variant's parent as the page, the twin and the JSON-LD name it (P3): its published row for the title and address,
* and the frozen copy of the version it was copied at. A parent that is a draft reads as unpublished: its name, no link.
*/
export async function lineageFor(env: Env, record: Pick<ProcedureRecord, "forkedFrom" | "profile">) {
const from = record.forkedFrom;
if (!from) return null;
const root = BASES.find((b) => b.profile === record.profile)?.entryRoot ?? "/research/protocols/";
const path = `${root}${from.slug}`;
const row = await getProcedureByPath(env, path);
const live = row && row.status === "published" ? { title: row.record.title, path: row.path } : null;
const frozenRow = from.version ? await getFrozenVersion(env, path, from.version) : null;
return resolveLineage(from, record.profile, { live, frozen: frozenRow ? { title: frozenRow.record.title } : null });
}