From e4ec84211abaec699778998bf2cf8425de261d23 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 12 Oct 2024 00:34:22 +0200 Subject: [PATCH] [rules] Rule Builder: Fix condition callback type def (#390) Signed-off-by: Florian Hotze --- src/rules/trigger-builder.js | 7 ++++++- types/rules/trigger-builder.d.ts | 12 ++++++++++-- types/rules/trigger-builder.d.ts.map | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/rules/trigger-builder.js b/src/rules/trigger-builder.js index b8ca6ed66..56ac0c61b 100644 --- a/src/rules/trigger-builder.js +++ b/src/rules/trigger-builder.js @@ -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 * @@ -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) { diff --git a/types/rules/trigger-builder.d.ts b/types/rules/trigger-builder.d.ts index 309733e41..6d77f86a4 100644 --- a/types/rules/trigger-builder.d.ts +++ b/types/rules/trigger-builder.d.ts @@ -1,3 +1,7 @@ +/** + * The callback function to determine if the condition is met. + */ +export type ConditionCallback = () => boolean; /** * Cron based trigger * @@ -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 * @@ -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 diff --git a/types/rules/trigger-builder.d.ts.map b/types/rules/trigger-builder.d.ts.map index 1abbfb82b..408c1f7ab 100644 --- a/types/rules/trigger-builder.d.ts.map +++ b/types/rules/trigger-builder.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../src/rules/trigger-builder.js"],"names":[],"mappings":"AAgNA;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,oBAAoB,CAIhC;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GACJ,oBAAoB,CAKhC;IAFC,kBAAgC;IAIlC,eAAe;IACf,kBAEC;CACF;AA4CD;;;;;;GAMG;AACH;IACE,gEAYC;IAVC,aAAyC;IAKzC,eAAe;IACf,kBAA2B;IA8G7B,eAAe;IACf,iBA6BC;IAzIC,oBAOW,iBAAiB,CAPX;IAGnB;;;;;OAKG;IACH,gBAFa,iBAAiB,CAK7B;IAFC,cAAqB;IAIvB;;;;OAIG;IACH,kBAFa,iBAAiB,CAQ7B;IAFC,gBAAuB;IAIzB;;;;OAIG;IACH,SAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,QAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,WAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,UAFa,iBAAiB,CAI7B;IAED;;;;OAIG;IACH,mBAFa,iBAAiB,CAK7B;IAFC,gBAAgC;IAIlC;;;;OAIG;IACH,kBAFa,iBAAiB,CAK7B;IAED;;;;OAIG;IACH,WAFa,iBAAiB,CAK7B;IAED;;;;OAIG;IACH,oBAFa,iBAAiB,CAI7B;IAED,eAAe;IACf,kBAEC;IAkCD,eAAe;IAC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,kBAAkB,CAI9B;IAED;;;;;OAKG;IACH,UAFa,mBAAmB,CAI/B;IAED;;;;;OAKG;IACH,mBAHW,MAAM,GACJ,qBAAqB,CAIjC;CACF;AAED;;;GAGG;AACH;IACE,iCAGC;IAFC,eAAe;IACf,uBAAoC;IAGtC;;;;OAIG;IACH,MAFa,cAAc,CAI1B;IAED;;;;;OAKG;IACH,gBAFa,WAAW,gBAAgB,CAIvC;IAED;;;;;OAKG;IACH,cAFa,WAAW,gBAAgB,CAIvC;CACF;AAuED;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAoE;IACpE,eAAe;IACf,iBAA4G;CAE/G;AA6XD;;;;;;GAMG;AACH;IACE,gDAcC;IAZC,eAAe;IACf,kBAAyB;IACzB,eAAe;IACf,kBAAsB;IACtB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAmG;IACnG,eAAe;IACf,iBAAwJ;IAG1J;;;;;OAKG;IACH,oBAHW,OAAO,GACL,qBAAqB,CAKjC;IAED;;;;;OAKG;IACH,mBAHW,MAAM,GACJ,qBAAqB,CAKjC;CACF"} \ No newline at end of file +{"version":3,"file":"trigger-builder.d.ts","sourceRoot":"","sources":["../../src/rules/trigger-builder.js"],"names":[],"mappings":";;;sCAMa,OAAO;AA+MpB;;;;;;GAMG;AACH;IACE,+CAUC;IARC,eAAe;IACf,gBAAsB;IACtB,eAAe;IACf,kBAA2B;IAC3B,eAAe;IACf,sBAAsE;IACtE,eAAe;IACf,iBAAgG;CAEnG;AAnED;;;;GAIG;AACH;IACE,mDAIC;IAFC,iBAA8B;IAC9B,mCAA2F;IAG7F,eAAe;IACf,iBAMC;IAED;;;;;OAKG;IACH,cAHW,MAAM,GACJ,oBAAoB,CAIhC;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GACJ,oBAAoB,CAKhC;IAFC,kBAAgC;I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