Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rules] Rule Builder: Fix condition callback type def #390

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading