UNPKG

single-source-of-truth

Version:
26 lines 993 B
import { pathToFileURL } from 'node:url'; import logger from "../../logger.js"; import { TruthEnum, TruthModel } from './export.js'; async function import_(registry, possiblePaths) { for (const relativePath of Array.isArray(possiblePaths) ? possiblePaths : [possiblePaths]) { const url = pathToFileURL(relativePath).toString(); logger.info(`Importing schemas from '${relativePath}'...`); const module = await import(url); for (const [name, target] of Object.entries(module)) { if (target instanceof TruthEnum) { target.def.name = name; registry.enums.set(name, target); } if (target instanceof TruthModel) { if (target.def.includes.length) continue; target.def.name = name; registry.models.set(name, target); } } } } export { import_ as import }; //# sourceMappingURL=config.js.map