/** * In-memory equivalent of what export-datasheets.js writes to * X:\For_Web\.TXT. Lets upload-to-api.js POST directly to Hoffman's API * from DB state without a filesystem intermediate. * * Returns a string (datasheet text) or null if the record cannot be rendered * (no specs for the model, no raw_data for VASLOG_ENG, etc.). */ const { loadAllSpecs, getSpecs } = require('../parsers/spec-reader'); const { generateExactDatasheet } = require('../templates/datasheet-exact'); let _specMap = null; function specs() { if (_specMap === null) _specMap = loadAllSpecs(); return _specMap; } function renderContent(record) { if (record.log_type === 'VASLOG_ENG') { return record.raw_data || null; } const modelSpecs = getSpecs(specs(), record.model_number); if (!modelSpecs) return null; return generateExactDatasheet(record, modelSpecs) || null; } module.exports = { renderContent };