| | |
| | | /** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */ |
| | | |
| | | /** |
| | | * Defines the keys of types type used by this module. |
| | | * @template T |
| | | * @template {T[keyof T]} V |
| | | * @typedef {import("./RuleSetCompiler").KeysOfTypes<T, V>} KeysOfTypes |
| | | */ |
| | | |
| | | /** @typedef {KeysOfTypes<RuleSetRule, { [k: string]: RuleSetConditionOrConditions }>} ObjectMatcherRuleKeys */ |
| | | /** @typedef {keyof EffectData} DataProperty */ |
| | | |
| | | const PLUGIN_NAME = "ObjectMatcherRulePlugin"; |
| | | |
| | | class ObjectMatcherRulePlugin { |
| | | /** |
| | | * Creates an instance of ObjectMatcherRulePlugin. |
| | | * @param {ObjectMatcherRuleKeys} ruleProperty the rule property |
| | | * @param {keyof EffectData=} dataProperty the data property |
| | | * @param {DataProperty=} dataProperty the data property |
| | | * @param {RuleConditionFunction=} additionalConditionFunction need to check |
| | | */ |
| | | constructor(ruleProperty, dataProperty, additionalConditionFunction) { |
| | | /** @type {ObjectMatcherRuleKeys} */ |
| | | this.ruleProperty = ruleProperty; |
| | | /** @type {DataProperty | ObjectMatcherRuleKeys} */ |
| | | this.dataProperty = dataProperty || ruleProperty; |
| | | /** @type {RuleConditionFunction | undefined} */ |
| | | this.additionalConditionFunction = additionalConditionFunction; |
| | | } |
| | | |
| | | /** |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {RuleSetCompiler} ruleSetCompiler the rule set compiler |
| | | * @returns {void} |
| | | */ |