integration layer; merge work on indicators from forks with existing ingestion pipeline

This commit is contained in:
Roberto Treviño Cervantes
2026-10-23 00:00:14 -06:00
parent b0608fdc70
commit d9245fe9b7
194 changed files with 21773 additions and 848 deletions
@@ -0,0 +1,44 @@
import { MappingSet } from './mapping-set';
describe('MappingSet', () => {
it('seeds from suggestions, skipping unmatched columns and keeping confidence', () => {
const set = new MappingSet();
set.seed([
{ source_column: 'a', target_field: 'x', confidence: 0.8, reason: 'synonym' },
{ source_column: 'b', target_field: null, confidence: 0, reason: 'none' },
]);
expect(set.items()).toEqual([{ source: 'a', field: 'x', confidence: 0.8, reason: 'synonym' }]);
});
it('keeps the mapping 1:1 in both directions', () => {
const set = new MappingSet();
set.assign('a', 'x');
set.assign('b', 'x'); // field x now fed by b
set.assign('b', 'y'); // column b moves to y
expect(set.toRecord()).toEqual({ b: 'y' });
});
it('fillFrom never overrides a manual choice', () => {
const set = new MappingSet();
set.assign('manual', 'x');
const added = set.fillFrom([
{ source_column: 'auto', target_field: 'x', confidence: 0.9, reason: 'normalized' },
{ source_column: 'other', target_field: 'y', confidence: 0.7, reason: 'fuzzy' },
]);
expect(added).toBe(1);
expect(set.toRecord()).toEqual({ manual: 'x', other: 'y' });
});
it('confirm drops the suggestion marker; release removes by field or by source', () => {
const set = new MappingSet();
set.seed([
{ source_column: 'a', target_field: 'x', confidence: 0.8, reason: 'synonym' },
{ source_column: 'b', target_field: 'y', confidence: 0.8, reason: 'synonym' },
]);
set.confirm('x');
expect(set.byField().get('x')).toEqual({ source: 'a', field: 'x' });
set.releaseField('x');
set.releaseSource('b');
expect(set.size()).toBe(0);
});
});