feat(domain): equine legacy importer (packages/anatomy) + generated official equine sheet seed as draft
This commit is contained in:
1 parent
f4682cdba5
commit
52bfc11553
43 files changed
+18466
-33
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { join } from 'node:path'
|
||||
import {
|
||||
EQUINE_SOURCE_PATHS,
|
||||
importEquineLegacy,
|
||||
readEquineSources,
|
||||
type EquineLegacyInput,
|
||||
type ImportResult,
|
||||
} from '../src'
|
||||
import type { LegacyCatalog } from '../src/legacy/catalog'
|
||||
|
||||
/** Tests run on the real legacy sources, never on copies. */
|
||||
export const REPO_ROOT = fileURLToPath(new URL('../../../', import.meta.url))
|
||||
|
||||
export function loadInput(): Promise<EquineLegacyInput> {
|
||||
return readEquineSources(REPO_ROOT)
|
||||
}
|
||||
|
||||
export async function runImport(): Promise<ImportResult> {
|
||||
return importEquineLegacy(await loadInput())
|
||||
}
|
||||
|
||||
export async function loadCatalog(): Promise<LegacyCatalog> {
|
||||
const text = await readFile(
|
||||
join(REPO_ROOT, EQUINE_SOURCE_PATHS.catalog),
|
||||
'utf8',
|
||||
)
|
||||
return JSON.parse(text) as LegacyCatalog
|
||||
}
|
||||
|
||||
export async function legacyAnnoIds(path: string): Promise<string[]> {
|
||||
const text = await readFile(join(REPO_ROOT, path), 'utf8')
|
||||
const ids = [...text.matchAll(/data-anno-id="([^"]+)"/g)].map((m) => m[1]!)
|
||||
return [...new Set(ids)]
|
||||
}
|
||||
Reference in new issue
Block a user