Skip to content

Commit

Permalink
[rules] Rule Builder: Fix condition callback type def (#390)
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Oct 11, 2024
1 parent 0ebd7e6 commit e4ec842
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/rules/trigger-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ const triggers = require('../triggers');
const operations = require('./operation-builder');
const conditions = require('./condition-builder');

/**
* @callback ConditionCallback The callback function to determine if the condition is met.
* @returns {boolean} true if the condition is met, otherwise false
*/

/**
* Builder for rule Triggers
*
Expand Down Expand Up @@ -150,7 +155,7 @@ class TriggerConf {
/**
* Move to the rule condition
*
* @param {*} [fn] the optional function to execute
* @param {ConditionCallback} [fn] the optional function to execute
* @returns {conditions.ConditionBuilder}
*/
if (fn) {
Expand Down
12 changes: 10 additions & 2 deletions types/rules/trigger-builder.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* The callback function to determine if the condition is met.
*/
export type ConditionCallback = () => boolean;
/**
* Cron based trigger
*
Expand Down Expand Up @@ -227,6 +231,10 @@ export class SystemTriggerConfig extends TriggerConf {
startLevel(level: number): SystemTriggerConfig;
level: number;
}
/**
* @callback ConditionCallback The callback function to determine if the condition is met.
* @returns {boolean} true if the condition is met, otherwise false
*/
/**
* Builder for rule Triggers
*
Expand Down Expand Up @@ -326,10 +334,10 @@ declare class TriggerConf {
/**
* Move to the rule condition
*
* @param {*} [fn] the optional function to execute
* @param {ConditionCallback} [fn] the optional function to execute
* @returns {conditions.ConditionBuilder}
*/
if(fn?: any): conditions.ConditionBuilder;
if(fn?: ConditionCallback): conditions.ConditionBuilder;
}
/**
* Time of day based trigger
Expand Down
2 changes: 1 addition & 1 deletion types/rules/trigger-builder.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e4ec842

Please sign in to comment.