UNPKG

@o3r/rules-engine

Version:

This module provides a rule engine that can be executed on your Otter application to customize your application (translations, placeholders and configs) based on a json file generated by your CMS.

74 lines 3.14 kB
import { Store } from '@ngrx/store'; import type { RulesEngineActionHandler } from '@o3r/core'; import { LoggerService } from '@o3r/logger'; import { BehaviorSubject, Observable } from 'rxjs'; import type { ActionBlock, Fact, Operator, Ruleset, UnaryOperator } from '../../engine/index'; import { RulesEngine } from '../../engine/index'; import type { RulesetsStore } from '../../stores'; import { RulesEngineServiceOptions } from '../rules-engine.token'; import * as i0 from "@angular/core"; export declare class RulesEngineRunnerService { private readonly store; private readonly logger; /** Rulesets to restrict the execution of the engine */ protected ruleSets$: Observable<string[] | undefined>; /** Observable of component linked to the component */ protected linkedComponents$: BehaviorSubject<{ [key: string]: number; }>; /** Map of engines dedicated to each rule sets */ readonly engine: RulesEngine; /** stream of the whole ruleset results */ events$: Observable<ActionBlock[]>; /** Enable action execution on new state change */ enabled: boolean; /** * List of action handlers * @deprecated will become protected in Otter v13, instead use {@link registerActionHandlers} */ readonly actionHandlers: Set<RulesEngineActionHandler<import("@o3r/core").RulesEngineAction<string, any>>>; constructor(store: Store<RulesetsStore>, logger: LoggerService, engineConfig?: RulesEngineServiceOptions); /** * Execute the list of actions * @param actions */ protected executeActions(actions: ActionBlock[]): Promise<void>; /** * Update or insert fact in the rules engine * @param facts fact list to add / update */ upsertFacts(facts: Fact<unknown> | Fact<unknown>[]): void; /** * Update or insert operator in the rules engine * @param operators operator list to add / update */ upsertOperators(operators: (Operator<any, any> | UnaryOperator<any>)[]): void; /** * Upsert a list of RuleSets to be run in the rules engine * @param ruleSets */ upsertRulesets(ruleSets: Ruleset[]): void; /** * Add action handlers in the rules engine * @param actionHandlers */ registerActionHandlers(...actionHandlers: RulesEngineActionHandler[]): void; /** * Remove action handlers in the rules engine * @param actionHandlers */ unregisterActionHandlers(...actionHandlers: RulesEngineActionHandler[]): void; /** * Enable temporary a rule set * @param componentComputedName Name of the component to enable the ruleset for */ enableRuleSetFor(componentComputedName: string): void; /** * Disable temporary a rule set * @param componentComputedName Name of the component to disable the ruleset for */ disableRuleSetFor(componentComputedName: string): void; static ɵfac: i0.ɵɵFactoryDeclaration<RulesEngineRunnerService, [null, null, { optional: true; }]>; static ɵprov: i0.ɵɵInjectableDeclaration<RulesEngineRunnerService>; } //# sourceMappingURL=rules-engine.runner.service.d.ts.map