Skip to content

Commit

Permalink
Merge pull request #13 from bcgov/feature/support-rule-linking
Browse files Browse the repository at this point in the history
Update decision handling to be able to manage linking decisions
  • Loading branch information
timwekkenbc authored Jul 2, 2024
2 parents 352ada8 + f5ad232 commit 723a6a7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/decisions/decisions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ export class DecisionsService {
rulesDirectory: string;

constructor(private configService: ConfigService) {
this.engine = new ZenEngine();
this.rulesDirectory = this.configService.get<string>('RULES_DIRECTORY');
const loader = async (key: string) => readFileSafely(this.rulesDirectory, key);
this.engine = new ZenEngine({ loader });
}

async runDecision(content: object, context: object, options: ZenEvaluateOptions) {
try {
const decision = this.engine.createDecision(content);
return await decision.evaluate(context, options);
} catch (error) {
console.error(error.message);
throw new Error(`Failed to run decision: ${error.message}`);
}
}
Expand Down

0 comments on commit 723a6a7

Please sign in to comment.