Skip to content
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
13 changes: 9 additions & 4 deletions src/rules/condition-builder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
const operations = require('./operation-builder');
const items = require('../items/items');

/**
* @typedef { import("./rules").RuleCallback } RuleCallback
* @private
*/

/**
* Condition that wraps a function to determine whether if passes
*
Expand All @@ -23,7 +28,7 @@ class ConditionBuilder {
/**
* Move to the rule operations
*
* @param {*} [fn] the optional function to execute
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then (fn) {
Expand Down Expand Up @@ -57,9 +62,9 @@ class ConditionConf {
}

/**
* @param {*} [fn] an optional function
* @returns {operations.OperationBuilder}
*/
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then (fn) {
return this.conditionBuilder._then(this, fn);
}
Expand Down
9 changes: 7 additions & 2 deletions src/rules/trigger-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const conditions = require('./condition-builder');
* @private
*/

/**
* @typedef { import("./rules").RuleCallback } RuleCallback
* @private
*/

/**
* @callback ConditionCallback The callback function to determine if the condition is met.
* @returns {boolean} true if the condition is met, otherwise false
Expand Down Expand Up @@ -150,7 +155,7 @@ class TriggerConf {
/**
* Move to the rule operations
*
* @param {*} [fn] the optional function to execute
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then (fn) {
Expand All @@ -160,7 +165,7 @@ class TriggerConf {
/**
* Move to the rule condition
*
* @param {ConditionCallback} [fn] the optional function to execute
* @param {ConditionCallback} [fn] the optional function to check for conditions when the rule is triggered
* @returns {conditions.ConditionBuilder}
*/
if (fn) {
Expand Down
17 changes: 11 additions & 6 deletions types/rules/condition-builder.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export type RuleCallback = import("./rules").RuleCallback;
/**
* Condition that wraps a function to determine whether if passes
*
Expand Down Expand Up @@ -61,6 +62,10 @@ export class ItemStateConditionConf extends ConditionConf {
/** @private */
private check;
}
/**
* @typedef { import("./rules").RuleCallback } RuleCallback
* @private
*/
/**
* Condition that wraps a function to determine whether if passes
*
Expand All @@ -77,10 +82,10 @@ export class ConditionBuilder {
/**
* Move to the rule operations
*
* @param {*} [fn] the optional function to execute
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then(fn?: any): operations.OperationBuilder;
then(fn?: RuleCallback): operations.OperationBuilder;
/**
* Condition of an item in determining whether to process rule.
*
Expand All @@ -98,10 +103,10 @@ declare class ConditionConf {
/** @private */
private conditionBuilder;
/**
* @param {*} [fn] an optional function
* @returns {operations.OperationBuilder}
*/
then(fn?: any): operations.OperationBuilder;
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then(fn?: RuleCallback): operations.OperationBuilder;
}
import operations = require("./operation-builder");
export {};
Expand Down
2 changes: 1 addition & 1 deletion types/rules/condition-builder.d.ts.map

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

47 changes: 13 additions & 34 deletions types/rules/trigger-builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ export type Item = {
persistence: import("../items/item-persistence");
semantics: import("../items/item-semantics");
readonly type: string;
/** @private */
readonly groupType: string;
readonly name: string;
readonly label: string;
readonly state: string;
readonly numericState: number;
readonly quantityState: import("../quantity").Quantity;
readonly boolState: boolean;
readonly rawState: HostState; /**
* Item state changed from
*
* @param {string} value
* @returns {ItemTriggerConfig}
*/
readonly rawState: HostState;
readonly previousState: string;
readonly previousNumericState: number;
readonly previousQuantityState: import("../quantity").Quantity;
Expand All @@ -33,46 +27,26 @@ export type Item = {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any; /**
* Specifies a time schedule for the rule to fire.
*
* @param {string} time the time expression (in `HH:mm`) defining the triggering schedule
* @returns {TimeOfDayTriggerConfig} the trigger config
*/
toString(): any;
} | {
namespace: {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any; /**
* Specifies a time schedule for the rule to fire.
*
* @param {string} time the time expression (in `HH:mm`) defining the triggering schedule
* @returns {TimeOfDayTriggerConfig} the trigger config
*/
toString(): any;
};
};
replaceMetadata(namespace: string, value: string, configuration?: any): {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any; /**
* Specifies a time schedule for the rule to fire.
*
* @param {string} time the time expression (in `HH:mm`) defining the triggering schedule
* @returns {TimeOfDayTriggerConfig} the trigger config
*/
toString(): any;
};
removeMetadata(namespace?: string): {
rawMetadata: any;
readonly value: string;
readonly configuration: any;
toString(): any; /**
* Specifies a time schedule for the rule to fire.
*
* @param {string} time the time expression (in `HH:mm`) defining the triggering schedule
* @returns {TimeOfDayTriggerConfig} the trigger config
*/
toString(): any;
};
sendCommand(value: any, expire?: JSJoda.Duration, onExpire?: any): void;
sendCommandIfDifferent(value: any): boolean;
Expand All @@ -90,6 +64,7 @@ export type Item = {
removeTags(...tagNames: string[]): void;
toString(): any;
};
export type RuleCallback = import("./rules").RuleCallback;
/**
* The callback function to determine if the condition is met.
*/
Expand Down Expand Up @@ -330,6 +305,10 @@ export class SystemTriggerConfig extends TriggerConf {
* @typedef { import("../items/items").Item } Item
* @private
*/
/**
* @typedef { import("./rules").RuleCallback } RuleCallback
* @private
*/
/**
* @callback ConditionCallback The callback function to determine if the condition is met.
* @returns {boolean} true if the condition is met, otherwise false
Expand Down Expand Up @@ -426,14 +405,14 @@ declare class TriggerConf {
/**
* Move to the rule operations
*
* @param {*} [fn] the optional function to execute
* @param {RuleCallback} [fn] the optional callback function to execute when the rule is run
* @returns {operations.OperationBuilder}
*/
then(fn?: any): operations.OperationBuilder;
then(fn?: RuleCallback): operations.OperationBuilder;
/**
* Move to the rule condition
*
* @param {ConditionCallback} [fn] the optional function to execute
* @param {ConditionCallback} [fn] the optional function to check for conditions when the rule is triggered
* @returns {conditions.ConditionBuilder}
*/
if(fn?: ConditionCallback): conditions.ConditionBuilder;
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.