UNPKG

@just-in/core

Version:

A TypeScript-first framework for building adaptive digital health interventions.

37 lines 1.76 kB
import { DecisionRule, DecisionRuleRegistration } from './handler.type'; import { JEvent } from '../event/event.type'; import { JUser } from '../user-manager/user.type'; /** * Registers a DecisionRule by adding it to the `decisionRules` map. * Sets the `type` property to `DECISION_RULE`. * * @param {DecisionRuleRegistration} rule - The decision rule to register. * @returns {void} * * @example * registerDecisionRule({ name: "checkWeather", shouldDecide: ..., decide: ..., doAction: ... }); * // Logs: "Decision rule 'checkWeather' registered successfully." */ export declare const registerDecisionRule: (rule: DecisionRuleRegistration) => void; /** * Retrieves a DecisionRule by its name from the internal `decisionRules` map. * * @param {string} name - The name of the DecisionRule to retrieve. * @returns {DecisionRule | undefined} - The DecisionRule object if found, otherwise `undefined`. */ export declare const getDecisionRuleByName: (name: string) => DecisionRule | undefined; /** * Executes a full DecisionRule workflow, including `shouldDecide`, `decide`, and `doAction` steps. * This ensures a complete decision-making process and records results for each step. * * @param {DecisionRule} rule - The decision rule to execute. * @param {JEvent} event - The event triggering the decision rule. * @param {JUser} user - The user for whom the decision rule is processed. * @returns {Promise<void>} - Resolves when all steps are complete. * * @example * const rule = getDecisionRuleByName("checkWeather"); * if (rule) await executeDecisionRule(rule, event, user); */ export declare function executeDecisionRule(rule: DecisionRule, event: JEvent, user: JUser): Promise<void>; //# sourceMappingURL=decision-rule.manager.d.ts.map