Skip to content

Releases: aimidy/render-rules

v1.1.3

Choose a tag to compare

@aimidy aimidy released this 23 Oct 08:00

🧩 修正項目:Negated Rule Error Handling

此次更新重點針對 evaluateCondition
函式在處理「否定(not)」邏輯時的錯誤行為進行了修正。
原本在錯誤發生時,系統可能誤將結果反轉為 true,導致條件判斷不準確。
此版本解決了該問題,確保當條件觸發 onError 時,返回結果為
false,而不會被錯誤地反轉。


🔍 主要變更內容

  1. 新增錯誤標識常數
    引入 EVALUATION_ERROR 符號以明確區分正常邏輯結果與異常情況。

  2. 重構核心邏輯

    • 將 evaluateCondition 拆分為
      evaluateConditionInternal,以更清楚地控制錯誤傳遞與回傳值。\
    • 在多層巢狀結構(如 any、all 群組)中,若遇錯誤,系統會標記
      encounteredError 並傳回
      EVALUATION_ERROR,而非直接反轉布林值。\
    • 若最終結果為 EVALUATION_ERROR,則會回傳 false。
  3. 測試覆蓋

    • 新增單元測試,確保 negated 條件與群組在觸發 onError
      時均不會被誤判為 true。\
    • 強化 onError 呼叫次數驗證,確保異常狀況被正確攔截。

✅ 改進效果

  • 準確性提升:錯誤不再導致條件結果反轉。\
  • 測試可靠度提升:擴充單元測試確保各種組合條件下邏輯正確。\
  • 可維護性提升:重構後的程式結構更清晰、錯誤傳遞機制更一致。

🧠 開發者備註

此修正特別針對使用 not
關鍵字的規則在遇到未知運算子或執行錯誤時的判定問題。
若你在整合規則引擎時使用自訂運算子,請留意 onError
回呼的正確設置,避免誤判情形。

What's Changed

  • Prevent negated rules from masking evaluation errors by @aimidy in #1

New Contributors

  • @aimidy made their first contribution in #1

Full Changelog: v1.1.2...v1.1.3

v1.1.2

Choose a tag to compare

@aimidy aimidy released this 05 Sep 07:18

🚀 Release v1.1.2 - API Simplification: Remove Context Parameter

📋 Overview

This release simplifies the evaluateCondition API by removing the unused context parameter, making the function signature cleaner and more focused on its core functionality.

⚠️ Breaking Changes

Function Signature Change

The evaluateCondition function signature has been simplified:

// Before (v1.1.1)
evaluateCondition(rule, row, context = {}, options = {})

// After (v1.1.2) 
evaluateCondition(rule, row, options = {})

📝 Migration Guide

If you're currently using the context parameter, simply remove it from your function calls:

// Before
evaluateCondition(rule, row, context, options)

// After
evaluateCondition(rule, row, options)

✨ What's Changed

🗑️ Removed

  • context parameter from evaluateCondition function
  • context parameter from internal helper functions
  • All context-related documentation and examples
  • Context functionality tests (8 test cases removed)

�� Updated

  • Function signatures for all evaluation functions
  • JSDoc documentation to reflect new parameter structure
  • All test cases to use simplified function calls
  • README examples to match new API

🧪 Testing

  • All 78 existing tests continue to pass
  • No functionality was lost in this simplification
  • Error handling and options configuration remain unchanged

📊 Impact

  • API Surface: Reduced from 4 parameters to 3 parameters
  • Bundle Size: Slightly reduced due to removed unused code paths
  • Backward Compatibility: Breaking change - requires code updates
  • Performance: No performance impact (context was unused)

🔗 Full Changelog

  • Remove unused context parameter from evaluateCondition function
  • Update all internal function signatures to remove context parameter
  • Simplify function documentation and remove context references
  • Update all test cases to use new simplified API
  • Update README examples to match new function signature
  • Maintain full backward compatibility for all other functionality

📦 Installation

npm install @aimidy/render-rules@1.1.2

🤝 Contributing

We welcome contributions! Please see our GitHub repository for more information.


Note: This is a breaking change release. Please update your code to remove the context parameter from evaluateCondition function calls.


📋 Technical Details

Files Modified

  • src/evaluateCondition.ts - Removed context parameter from all functions
  • src/evaluateCondition.test.ts - Updated all test cases and removed context tests
  • README.md - Updated examples to match new API
  • package.json - Version bump to 1.1.2

Test Results

  • ✅ 78 tests passing
  • ✅ No linting errors
  • ✅ All functionality preserved (except context parameter)

Breaking Change Impact

  • Severity: Medium (requires code changes but no logic changes)
  • Migration Effort: Low (simple parameter removal)
  • Risk: Low (context parameter was unused)

v1.1.1

Choose a tag to compare

@aimidy aimidy released this 05 Sep 06:21

Full Changelog: v1.1.0...v1.1.1

v1.1.0

Choose a tag to compare

@aimidy aimidy released this 22 Aug 07:38

Title render-rules v1.1.0 – Date/Time operators & enhanced docs

English (Release Notes) Highlights

  • Added comprehensive date/time comparison operators
  • Relative-now evaluation (minutes offset)
  • Expanded tests + updated README

Added

  • Operators: dateEquals, dateNotEquals, dateAfter, dateBefore, dateOnOrAfter, dateOnOrBefore
  • Relative time: nowAfterPlusMinutes, nowBeforePlusMinutes
  • README: usage examples, operator tables
  • Jest test coverage for new operators (absolute + relative)

Changed

  • Documentation refined for clarity on array row OR semantics and invalid date handling.

Fixed

  • Consistent false returns on invalid date inputs (including dateNotEquals per current implementation expectations).

Breaking Changes

  • None.

Upgrade Notes

  • No code changes required; you may start using new operators in your rule definitions.
  • nsure your date strings are ISO 8601 or provide Date / timestamp numbers.

Example Usage

{ field: 'startAt', operator: 'dateAfter', value: '2024-01-01T09:00:00.000Z' }
{ field: 'endAt', operator: 'dateOnOrBefore', value: '2024-01-01T12:00:00.000Z' }
{ field: 'startAt', operator: 'nowAfterPlusMinutes', value: 30 }

Chinese (釋出說明) 重點

  • 新增完整日期 / 時間比較運算子
  • 支援相對現在時間 (分鐘位移)
  • 增補測試與 README 說明

新增

  • 運算子:dateEquals, dateNotEquals, dateAfter, dateBefore, dateOnOrAfter, dateOnOrBefore
  • 相對現在:nowAfterPlusMinutes, nowBeforePlusMinutes
  • README 範例與對照表
  • 新日期 / 相對時間 Jest 測試

變更

  • 文件強化:陣列資料 OR 行為、無效日期處理說明。

修正

  • 無效日期一律回傳 false(含 dateNotEquals 目前實作)。

相容性

  • 無破壞性變更。

升級指引

  • 直接升級即可使用新運算子。
  • 請提供合法 ISO / Date / timestamp。