/** * 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, rendersWithoutSpecs } = 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); // DSCA33/45 lost their spec files in the wipe but render from the Hoffman-mined // templates (template-driven names/specs + verbatim accuracy header), so allow a // null-specs render for them. generateExactDatasheet still gates on per-model // validation and returns null until the model is verified. if (!modelSpecs && !rendersWithoutSpecs(record.model_number)) return null; return generateExactDatasheet(record, modelSpecs) || null; } module.exports = { renderContent };