260322:1648 Correct Coresspondence / Doing RFA / Correct CI
This commit is contained in:
@@ -9,37 +9,41 @@ try {
|
||||
if (!fs.existsSync(config.SOURCE_PDF_DIR)) {
|
||||
throw new Error(`PDF Source directory not found at: ${config.SOURCE_PDF_DIR}`);
|
||||
}
|
||||
|
||||
|
||||
const files = fs.readdirSync(config.SOURCE_PDF_DIR);
|
||||
|
||||
|
||||
// Check write permission to log path
|
||||
fs.writeFileSync(`${config.LOG_PATH}/.preflight_ok`, new Date().toISOString());
|
||||
|
||||
|
||||
// Grab categories out of the previous node (Fetch Categories) if available
|
||||
// otherwise use fallback array
|
||||
let categories = ['Correspondence','RFA','Drawing','Transmittal','Report','Other'];
|
||||
let categories = ['Correspondence', 'RFA', 'Drawing', 'Transmittal', 'Report', 'Other'];
|
||||
try {
|
||||
const upstreamData = $('Fetch Categories').first()?.json?.data;
|
||||
if (upstreamData && Array.isArray(upstreamData)) {
|
||||
categories = upstreamData.map(c => c.name || c.type || c); // very loose mapping depending on API response
|
||||
categories = upstreamData.map((c) => c.name || c.type || c); // very loose mapping depending on API response
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
} catch (e) {}
|
||||
|
||||
// Grab existing tags from Fetch Tags node
|
||||
let existingTags = [];
|
||||
try {
|
||||
const tagData = $('Fetch Tags').first()?.json?.data || [];
|
||||
existingTags = Array.isArray(tagData) ? tagData.map(t => t.tag_name || t.name || '').filter(Boolean) : [];
|
||||
} catch(e) {}
|
||||
|
||||
return [{ json: {
|
||||
preflight_ok: true,
|
||||
pdf_count_in_source: files.length,
|
||||
excel_target: config.EXCEL_FILE,
|
||||
system_categories: categories,
|
||||
existing_tags: existingTags,
|
||||
timestamp: new Date().toISOString()
|
||||
}}];
|
||||
existingTags = Array.isArray(tagData) ? tagData.map((t) => t.tag_name || t.name || '').filter(Boolean) : [];
|
||||
} catch (e) {}
|
||||
|
||||
return [
|
||||
{
|
||||
json: {
|
||||
preflight_ok: true,
|
||||
pdf_count_in_source: files.length,
|
||||
excel_target: config.EXCEL_FILE,
|
||||
system_categories: categories,
|
||||
existing_tags: existingTags,
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
},
|
||||
];
|
||||
} catch (err) {
|
||||
throw new Error(`Pre-flight check failed: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user