Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions listener/src/utils/batch-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,44 @@ export class BatchValidator {
}

function runTerminalSimulation() {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const log = require('./logger').default as typeof import('./logger').default;

const sampleMockBatch = [
{ id: 'evt_001', recipient: 'discord_channel_alpha', channel: 'discord', message: 'TaskCreated: Bounty #42 active.' },
{ id: 'evt_002', recipient: 'discord_channel_alpha', channel: 'discord', message: 'WorkSubmitted: Task completed.' },
{ id: 'evt_003', recipient: '', channel: 'webhook', message: 'Missing recipient details' },
];

console.log('🚀 Running NotifyChain Batch Validation Check...');
log.info('Running NotifyChain Batch Validation Check');

const validationReport = BatchValidator.validateBatch(sampleMockBatch);

const reportsDir = path.join(__dirname, '../../reports');
if (!fs.existsSync(reportsDir)) {
fs.mkdirSync(reportsDir, { recursive: true });
}

fs.writeFileSync(
path.join(reportsDir, 'last-validation-run.json'),
JSON.stringify(validationReport, null, 2),
'utf-8'
);

console.log(`\n📊 Execution Results Logged:`);
console.log(` Status: ${validationReport.isValid ? '🟩 PASSED' : '🟥 REJECTED'}`);
console.log(` Errors Found: ${validationReport.errors.length}`);
validationReport.errors.forEach((err) => console.log(` ⚠️ ${err.message}`));
console.log(`\n💾 Saved audit report to: listener/reports/last-validation-run.json`);
const reportPath = path.join(reportsDir, 'last-validation-run.json');
fs.writeFileSync(reportPath, JSON.stringify(validationReport, null, 2), 'utf-8');

log.info('Batch validation complete', {
status: validationReport.isValid ? 'PASSED' : 'REJECTED',
processedCount: validationReport.processedCount,
errorCount: validationReport.errors.length,
reportPath,
});

if (!validationReport.isValid) {
validationReport.errors.forEach((err) => {
log.warn('Validation error detail', {
index: err.index,
field: err.field,
code: err.code,
message: err.message,
});
});
}
}

if (require.main === module) {
Expand Down
Loading
Loading