feat(domain): sheet document schema v2 — references registry, review_status, vertebral count_range; SQL gate + pgTAP 008
This commit is contained in:
1 parent
6c5b2b7754
commit
3dbbfdf1df
19 files changed
+474
-71
No files matched your search
@@ -2,7 +2,6 @@ import type {
|
||||
FindingCategoryKind,
|
||||
FindingNodeInput,
|
||||
LocalizedOptionalText,
|
||||
SourceRef,
|
||||
} from '@faunosteo/domain'
|
||||
import { isStableId, slugify } from './ids'
|
||||
import type { Anomaly, ZoneStats } from './types'
|
||||
@@ -21,7 +20,8 @@ export interface LegacyNode {
|
||||
description_fr?: string
|
||||
description_en?: string
|
||||
requires_vet_referral?: boolean
|
||||
sources?: SourceRef[]
|
||||
/** Inline citations of the legacy format; none exist, see importer guard. */
|
||||
sources?: unknown[]
|
||||
children?: LegacyNode[]
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ function mapNode(
|
||||
const text = description(node)
|
||||
if (text) out.description = text
|
||||
if (node.requires_vet_referral === true) out.requires_vet_referral = true
|
||||
if (node.sources) out.sources = node.sources.map((s) => ({ ...s }))
|
||||
if (node.children) {
|
||||
out.children = node.children.map((c) =>
|
||||
mapNode(c, [...path, node.id], state),
|
||||
|
||||
@@ -153,6 +153,7 @@ function buildDocument(
|
||||
`pathologies.json (schema ${sources.catalog.schema_version})`,
|
||||
},
|
||||
vertebral_config: { regions: vertebralRegions(sources.formula) },
|
||||
references: [],
|
||||
categories: mapped.categories.categories,
|
||||
views: buildViews(sources.assets),
|
||||
annotations: mapped.annotations.map((m) => m.annotation),
|
||||
@@ -226,6 +227,17 @@ function assertAnnotationsKept(stats: ImportStats): void {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The canonical document cites a shared references registry; the legacy
|
||||
* inline `sources` are not mapped. None exist today: refuse to drop any.
|
||||
*/
|
||||
function assertNoInlineSources(stats: ImportStats): void {
|
||||
if (stats.sources === 0) return
|
||||
throw new Error(
|
||||
`${stats.sources} inline legacy sources found: map them to references`,
|
||||
)
|
||||
}
|
||||
|
||||
function sourceAnomalies(
|
||||
sources: ParsedSources,
|
||||
stats: ImportStats,
|
||||
@@ -305,6 +317,7 @@ export function importEquineLegacy(input: EquineLegacyInput): ImportResult {
|
||||
const parsed = AnatomicalSheetDocumentSchema.parse(document)
|
||||
const stats = buildStats(sources, document, mapped)
|
||||
assertAnnotationsKept(stats)
|
||||
assertNoInlineSources(stats)
|
||||
return {
|
||||
document,
|
||||
legacyIdMap: buildIdMap(sources, mapped),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SHEET_DOCUMENT_SCHEMA_VERSION } from '@faunosteo/domain'
|
||||
import { AUTHORED_LABEL_CODE, regionLabelSubject } from './authored-labels'
|
||||
import { countTree } from './catalog'
|
||||
import type { Anomaly, ImportResult } from './types'
|
||||
@@ -269,7 +270,7 @@ function anomaliesSection(result: ImportResult): string {
|
||||
/** Source keys the document does not carry, and where they live now. */
|
||||
const NOT_CARRIED_OVER = [
|
||||
'`schema_version` du catalogue (`2.0`) : version du format historique, ' +
|
||||
'remplacée par `schema_version: 1` du document canonique ; la valeur ' +
|
||||
`remplacée par \`schema_version: ${SHEET_DOCUMENT_SCHEMA_VERSION}\` du document canonique ; la valeur ` +
|
||||
"d'origine est citée dans `attribution.notes`.",
|
||||
'bloc `species` du catalogue (`equine`, Cheval / Horse) : porté par ' +
|
||||
'`species_id` du document et par la table `public.species` ; le nom ' +
|
||||
|
||||
Reference in new issue
Block a user