diff --git a/src/api/ruleMapping/ruleMapping.service.spec.ts b/src/api/ruleMapping/ruleMapping.service.spec.ts index d622b00..7a3b4cf 100644 --- a/src/api/ruleMapping/ruleMapping.service.spec.ts +++ b/src/api/ruleMapping/ruleMapping.service.spec.ts @@ -146,7 +146,7 @@ describe('RuleMappingService', () => { type: 'expressionNode', content: { expressions: [ - { key: 'expr1', value: 'field3' }, + { key: 'expr1', value: 'field3 > 5' }, { key: 'expr2', value: 'complexExpr + 2' }, ], }, @@ -157,7 +157,7 @@ describe('RuleMappingService', () => { const result = await service.extractFields(nodes, 'inputs'); expect(result).toEqual({ inputs: [ - { key: 'expr1', property: 'field3', exception: null }, + { key: 'expr1', property: 'expr1', exception: 'field3 > 5' }, { key: 'expr2', property: 'expr2', exception: 'complexExpr + 2' }, ], }); diff --git a/src/api/ruleMapping/ruleMapping.service.ts b/src/api/ruleMapping/ruleMapping.service.ts index 4580027..15b9e16 100644 --- a/src/api/ruleMapping/ruleMapping.service.ts +++ b/src/api/ruleMapping/ruleMapping.service.ts @@ -64,11 +64,7 @@ export class RuleMappingService { const results = await Promise.all(promises); const fields = results.flat(); - const uniqueFieldsMap = new Map(); - - fields.forEach((field) => { - uniqueFieldsMap.set(field.property, field); - }); + const uniqueFieldsMap = new Map(fields.map((field) => [field.property, field])); const uniqueFields = Array.from(uniqueFieldsMap.values()); return { [fieldKey]: uniqueFields };